
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- 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 6710 Articles for Javascript

1K+ Views
Const and let were introduced in ES2015 to declare block scoped variables. While variables declared using let can be reassigned, they cannot be reassigned if they were declared using const.Following is the code showing let and const in JavaScript −Example Live Demo Document body { font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif; } .result, .sample { font-size: 20px; font-weight: 500; } Const and let in JavaScript CLICK HERE Click on the above button to reassign const and let ... Read More

221 Views
Adding and accessing object methods are common tasks in JavaScript. JavaScript objects are collections of properties and methods, and the JavaScript methods are functions associated with objects. JavaScript provides various features and ways to add and access object methods. In this article, we will understand how to add or access object methods in JavaScript. Understanding JavaScript Object Methods JavaScript methods are functions associated with objects. They allow objects to perform actions, which is important for creating dynamic and interactive programs. Methods in objects are functions that work with the object's properties. This helps make programming more organized and efficient. ... Read More

221 Views
To declare block scoped variables, we use the keyword let and const introduced in ES2015.Following is the code showing declaring black scoped variables in JavaScript −Example Live Demo Document body { font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif; } .result, .sample { font-size: 20px; font-weight: 500; } Declaring block scoped variables CLICK HERE Click on the above button to declare and display block scoped variables let resEle = document.querySelector(".result"); let sampleEle = document.querySelector(".sample");{ ... Read More

299 Views
Following is the code for removing elements using splice() method in JavaScript −Example Live Demo Document body { font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif; } .sample,.result { font-size: 20px; font-weight: 500; } Remove elements using splice() CLICK HERE Click on the above button to remove elements between 1st and 5th element let fillEle = document.querySelector(".sample"); let resEle = document.querySelector(".result"); let arr = [1, 3, 5, 7, 9, 11]; fillEle.innerHTML = arr; document.querySelector(".Btn").addEventListener("click", () => { arr.splice(1, 4); resEle.innerHTML = "Spliced array = " + arr; }); OutputThe above code will produce the following output −On clicking the ‘CLICK HERE’ button −

162 Views
The Array.prototype.find() method returns the first element value that satisfy a given condition in an array.Following is the code for the Array.prototype.find() method −Example Live Demo Document body { font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif; } .find { font-size: 20px; font-weight: 500; } JavaScript Array Find() example CLICK HERE Click on the above button to find lion among the animals function findLion(animal) { return animal === "lion"; } let fillEle = ... Read More

318 Views
The error object is basically thrown by the JavaScript interpreter when a script error occurs. This error object can also be thrown as exception for user defined exceptions. The two javaScript error object properties are −PropertyDescriptionnameIt sets or returns the name of the error.messageIt sets or returns the error message as stringFollowing is the code for error object in JavaScript −Example Live Demo Document body { font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif; } .result { font-size: 20px; font-weight: 500; } ... Read More

311 Views
Block scope is an area between two { curly braces } which can be between loops, if condition or switch statement. The let and const introduced in ES2015 allow us to create block scoped variables that can be accessed only inside those block.Following is the code showing block scoping in JavaScript −Example Live Demo Document body { font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif; } .result{ font-size: 20px; font-weight: 500; } Block scoping in JavaScript CLICK HERE Click on ... Read More

138 Views
Following is the code on invoking a function as a function and method −Example Live Demo Document body { font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif; } .result{ font-size: 20px; font-weight: 500; } Invoke a function as function and method CLICK HERE Click on the above button to invoke function as function and method let resEle = document.querySelector(".result"); function add(a, b){ return a+b; } let obj = { ... Read More

985 Views
Function parameters are the names of variables present in the function definition. Function arguments are the real values that are passed to the function and received by them.Following is the code showing parameters and arguments in JavaScript −Example Live Demo Document body { font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif; } .result, .sample{ font-size: 20px; font-weight: 500; } Function parameters and arguments CLICK HERE Click on the above button to pass the above values as arguments to ... Read More

569 Views
The encodeURI() function encodes the complete URI including special characters except except (, / ? : @ & = + $ #) characters.The decodeURI() function decodes the URI generated by the encodeURI() function.Following is the code for encodeURI() and decodeURI() functions in JavaScript −Example Live Demo Document body { font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif; } .encode, .decode { font-size: 18px; font-weight: 500; } encodeURI() and decodeURI() function in JavaScript ENCODE URI DECODE URI Click on ... Read More