Câu hỏi và câu trả lời về mã hóa JavaScript pdf
JavaScript is one of the most popular programming languages, developed by Brendan Eich in 1995 to create dynamic web pages. To build a career in web development, one needs to understand JavaScript in detail and look out for JavaScript interview questions to crack the interview Show
Worried where to get in-depth JavaScript interview questions? Don’t worry. We are here to help you out with the JavaScript interview questions The below list covers everything there is about JavaScript Interview Questions JavaScript Interview Questions for Freshers1. What is JavaScript?JavaScript is a client-side scripting language as well as a server-side scripting language. This scripting language can be written into HTML pages (also could use CSS for styling the pages), and web browsers understand the page This scripting language also acts like an object-oriented programming language but not a class-based object-oriented language 2. Who developed JavaScript, and what is the first name of JavaScript?JavaScript was created by a Netscape programmer, Brendan Eich He developed this new scripting language in just ten days At the time of launch, it was initially named Mocha, after which it was known as Live Script and later known as JavaScript 3. What are the differences between Java and JavaScript?JavaJavaScriptJava is a complete programming language that can be used for backend coding. JavaScript is a coded program that can be introduced to HTML pages (otherwise known as server-side scripting language). Java is an object-oriented programming (OOPS) or structured programming languages like C++ or C and . net. JavaScript is a client-side scripting language (not fully OOP). Java creates applications that run in a virtual machine or browserJavaScript code is run on a browser only. Java code needs to be compiledJavaScript code is all in text4. What are the JavaScript Data Types?Following are the Data types present in JavaScript Basically, there are two types of JavaScript Data types
5. Why Should We Study JavaScript?JavaScript is one of the three languages all web developers must learn for the following reasons
6. What is the basic use of the is NaN function in JavaScript?Hàm trả về true nếu đối số không phải là số. Nếu đối số là một số, thì nó trả về là false 7. Ai nhanh hơn giữa JavaScript và ASP Script?JavaScript nhanh hơn JavaScript is more rapid because, as JS is a client-side language and that it does not need any assistance or help of the webserver to execute, but on the other hand, ASP is a server-side language. That’s why ASP is always slower than JavaScript JS now is also known as a server-side language named NodeJS 8. What do you mean by negative infinity?Negative Infinity is nothing but a number in JavaScript that can be derived by dividing negative numbers by zero. This could be generated by arithmetic operations 9. Can we break JavaScript Code into several lines? If yes, then How?Yes, We can break JavaScript code into several lines; we can break within a string statement using a backslash (‘\’) at the end of the first line code For example,
And when you are not within a strong statement and want to change to a new line, then JavaScript ignores the break in the line For Example
The above code is perfect for better understanding, but it might hamper our debugging, so it is not advisable to write 10. What are undeclared and undefined variables?When variables are not declared in a program, then it is known as Undeclared Variables If no variable exists in our program and the program wants to read those variables, it will generate a runtime error When there is the declaration of a variable given no value to the variable inside a program is known as an Undefined Variable When a program wants to read the variable’s value, then the undefined values are returned JavaScript Coding Questions11. Write a code for adding new elements dynamically in JavaScript?
This is a simple code for representing how to add new elements dynamically So, at first, we set the boilerplate of HTML or the HTML structure. After that, we mention or indicate to DOM that it is a JavaScript file After that, we tell a function addNode, then we create an element of p or paragraph type, then we create text node by applying createTextNode (“This is a new text node”); then we will append or assign the text to this p-type For execution, we specify dynamic then we can process our program by document.getElementbyid (“Dynamic”); and append our p-type then the code will successfully be executed12. What do you mean by global variables? Define the Declaration and Problem with Global Variable?The variable which has no scope or available throughout the length of the code is otherwise known as the Global variable For declaring a local variable, a var keyword is used. It is also applicable for declaring an object. When there is the commission of the var keyword, then the global variable is declared For Example
13. What is a prompt box?A prompt is a type of box. It allows the user to enter their input, provide a text box, number, and text provided by label and box 14. What do you mean by the ‘this’ keyword in JavaScript?In the case of Java, the ‘This’ keyword is used to point to the current object, but in JavaScript, the ‘This’ keyword refers to them from where it was called In other Words, we could say that the” this” keyword refers to the object it belongs to So, the ‘this’ keyword has different values according to or depending upon where it is used
Call() and apply() method refer ‘this’ to any object 15. Explain the working of timers in JavaScript?Timers are used to execute a bit of code at a set time and repeat the bit of code in a given interval Those working are done by using functions setTimeout, setInterval, clear interval Working of Functions The setTimeout(function, delay) function is used to start a timer, which calls a particular function after the, particularly mentioned delay The setInterval(function, delay) function is used to repeatedly execute the given function in the said delay and only stops when it is cancelled The clearInterval(id) function instructs or indicates the timer to stop (for stopping the given or mentioned function) The whole timers are operated within a single thread, and for his events might wait or queue up, they wait for their execution 16. How do we Define comment’s in JavaScript?Đối với nhận xét một dòng. -“//” is used For Multi line comments. -“/* is used for multi-line comment */” 17. What will be the output of the below code?
Ans. [0,1,10,22,3,4,6] and [22,10,6,4,3,1,0] The sort() method sorts the elements of an array. The sort order can be either alphabetic or numeric, and either ascending (up) or descending (down). By default, the sort() method sorts the values as strings in alphabetical and ascending order 18. Create a button element with a value attribute set to “CLICK ME and WAIT” and invoke a click event on the button, which calls a function that changes the button’s text value color to red. At the same time, this function also sets up a timed function using setTimeout() that sets the text color back to black after 5 seconds
19. What is the output of the below code?
Ans. Reference Error Variables with the const and let keyword are block-scoped. A block is anything between curly brackets ({ }). In this case, the curly brackets of the if/else statements. You cannot reference a variable outside of the block it’s declared in, a Reference Error gets thrown 20. Viết một số JavaScript sử dụng đồng hồ hiện tại và đưa ra thông báo cảnh báo nếu lớp khoa học kết thúc (Giả sử lớp kết thúc lúc 02 giờ. 30)Ans. Possible solution
|