- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 6704 Articles for Javascript
787 Views
This tutorial teaches us to convert the arguments object to array in JavaScript. Before we proceed with the tutorial, let’s look at the arguments object. In JavaScript, every function contains the ‘arguments’ object. It includes the values of all arguments we passed while calling or invoking the function.It is very similar to an array, but it is not an actual array.The ‘arguments’ object has a length property, and we can use it to know how many arguments are passed during the function call.We can access all values of the ‘arguments’ object like an array index property. For example, arguments[0] give ... Read More
646 Views
Arguments object is the arguments passed to a function. It is a variable accessible for all functions. Let’s say two arguments are passed to a function, then you can access them like the following:arguments[0] arguments[1]In the same way, you can use a type of with arguments in JavaScript. Firstly, let’s see how to work with the type of. The type of operator is a unary operator that is placed before its single operand, which can be of any type. ExampleThe following code shows how to implement type of operatorLive Demo var ... Read More
145 Views
Arguments object in JavaScript is an object, which represents the arguments to the function executing. Its syntax has two arguments:[function.]arguments[p]ExampleYou can try to run the following code to learn what are arguments object in JavaScriptLive Demo function functionArgument(val1, val2, val3) { var res = ""; res += "Expected Arguments: " + functionArgument.length; res += ""; res += "Current Arguments : " + arguments.length; res += ""; res += "Each argument = " for (p = 0; p < arguments.length; p++) { res += ""; res += functionArgument.arguments[p]; res += " "; } document.write(res); } functionArgument(20, 50, 80, "Demo Text!","Hello World", new Date())
2K+ Views
The interaction between HTML and JavaScript is handled through events. When a user accomplishes some action on the page, an event occurs. In this tutorial, we will learn how to register events in JavaScript. Let’s move forward to discuss this further. Using Inline Event Handlers Added as HTML Tag Attributes Here, we shall learn how this standard event registration works. Adding events to the DOM attribute is a regular practice. But this is a worse approach. Extending and maintaining the code becomes difficult as HTML and JavaScript come together. Second, if the code loads late when the user interacts with ... Read More
4K+ Views
This tutorial teaches us to save HTML locally with JavaScript.What is local storage?Local storage means storing content inside your web browser locally. It means it takes space on your computer to store the content rather than storing it on the server of the web application. It is one kind of web API that contains all browsers by default.Local storage generally stores the application data, user’s secession data, authentication token, and many other things. Before HTML5, developers used cookies to store the HTML content locally, but now every browser has local storage.Also, cookies only allow storage of a maximum of 4kb ... Read More
4K+ Views
To use OR condition in JavaScript IF statement, use the || operator i.e Logical OR operator. If any of the two operands are non-zero, then the condition becomes true.Here’s how you can use the operator || in JavaScriptExampleLive Demo var a = true; var b = false; document.write("(a || b) => "); result = (a || b); document.write(result);
79 Views
The for each...in loop iterates a variable overall value of the properties of objects. Note − The “for…each..in” is now deprecated. Do not use. SyntaxHere’s the syntax −for each (variablename in object) { statement or block to execute }ExampleHere’s an example, which will not run on any of the web browsers, since “for each..in” is now deprecated − var myObj = {myProp1:30, myProp2: 40}; var sum = 0; for each (var value in myObj) { sum += value; } document.write(sum);
5K+ Views
It’s not possible to edit a JavaScript alert box title due to security issues. Still, to edit an alert box to work it all web browsers, use custom JavaScript Modal Dialogs or jQuery plugins.You can also use a custom alert box like Sweet Alert to get a custom alert box, with a title of your choice:
300 Views
To create a custom object in JavaScript, try the following codeExampleLive Demo var dept = new Object(); dept.employee = "Amit"; dept.department = "Technical"; dept.technology ="Java"; document.getElementById("test").innerHTML = dept.employee + " is working on " + dept.technology + " technology.";
To Continue Learning Please Login
Login with Google