Found 693 Articles for Front End Scripts

ES6 Default Parameters in nested objects – JavaScript

AmitDiwan
Updated on 09-Nov-2020 09:06:58
Yes, you can pass default parameters in nested objects.Following is the code −ExampleFollowing is the code −function callBackFunctionDemo({ cl: { callFunctionName = "callBackFunction", values = 100 } = {} } = {}) {    console.log(callFunctionName);    console.log(values); } //This will print the default value. // 100 callBackFunctionDemo(); //This will print the given value. //500 callBackFunctionDemo({ cl: { values: 500 } });To run the above program, you need to use the following command −node fileName.js.Here, my file name is demo296.js.OutputThis will produce the following output on console −PS C:\Users\Amit\javascript-code> node demo296.js callBackFunction 100 callBackFunction 500

Sorting a JSON object in JavaScript

AmitDiwan
Updated on 21-Oct-2020 11:53:46
Suppose we have an object like this −const obj = {    key1: 56,    key2: 67,    key3: 23,    key4: 11,    key5: 88 };We are required to write a JavaScript function that takes in this object and returns a sorted array like this −const arr = [11, 23, 56, 67, 88];Here, we sorted the object values and placed them in an array.Therefore, let’s write the code for this function −ExampleThe code for this will be −const obj = {    key1: 56,    key2: 67,    key3: 23,    key4: 11,    key5: 88 }; const sortObject ... Read More

Difference between ASP and ASP.NET

Nitin Sharma
Updated on 09-Jun-2020 08:29:55
Both ASP and ASP.NET are the widely used languages for application and mainly the frontEnd development. Both the languages used for dynamic generation of web pages. The content generated through server-side scripting is then sent to the client’s web browser.Following are the important differences between ASP and ASP.NET.Sr. No.KeyASPASP.NET1DefinitionASP or also popularly known as Classic ASP developed by Microsoft is first Server-side scripting engine which is used for dynamic generation of web pages.ASP.NET, on the other hand, is a server-side web framework, open-source, which is designed for the generation of dynamic web pages.2Language typeASP is interpreted language that means the ... Read More

How to check whether a checkbox is checked with JavaScript?

AmitDiwan
Updated on 06-May-2020 13:30:44
To check whether a checkbox is checked with JavaScript, the code is as follows −Example Live Demo Displaying textBox when a checkbox is checked Checkbox: Checkbox is checked!!!    document.querySelector(".check").addEventListener("click", checkFunction);    function checkFunction() {       var checkBox = document.querySelector(".check");       var textBox = document.querySelector(".textBox");       if (checkBox.checked == true) {          textBox.style.display = "block";       } else {          textBox.style.display = "none";       }    } OutputThis will produce the following output −On clicking the checkbox −

How to create a modal image gallery with CSS and JavaScript?

AmitDiwan
Updated on 06-Apr-2020 12:10:49
Following is the code to create modal image gallery with CSS and JavaScript −Example Live Demo

HTML DOM hasFocus() method.

AmitDiwan
Updated on 19-Feb-2021 09:22:45
The HTML DOM hasFocus() method is used for knowing if the document or any element inside the document has focus. It does so by returning a boolean value in which true represents the document/element has focus and false represents otherwise.SyntaxFollowing is the syntax for hasFocus() method −document.hasFocus()ExampleLet us look at an example for the hasFocus() method −Live Demo hasFocus() method Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. CHECK ... Read More

Map.entries() function in JavaScript

Samual Sam
Updated on 25-Jun-2020 12:13:29
The entries() function of Map object returns an iterator of the corresponding Map object and using this you can retrieve the key Value pairs of the map.SyntaxIts Syntax is as followsmapVar.entries()Example Live Demo    JavaScript Example           var mapVar = new Map();       mapVar.set('1', 'Java');       mapVar.set('2', 'JavaFX');       mapVar.set('3', 'HBase');       mapVar.set('4', 'Neo4j');       var it = mapVar.entries();       for(i=0; i

Date.valueOf() function in JavaScript

karthikeya Boyini
Updated on 25-Jun-2020 12:04:11
The Date object is a data type built into the JavaScript language. Date objects are created with the new Date( ) as shown below.Once a Date object is created, a number of methods allow you to operate on it. Most methods simply allow you to get and set the year, month, day, hour, minute, second, and millisecond fields of the object, using either local time or UTC (universal, or GMT) time.The valueOf() function of the date object returns its primitive value.SyntaxIts Syntax is as followsdateObj.valueOf()Example Live Demo    JavaScript Example           var dateObj = ... Read More

Date.toUTCString() function in JavaScript

Samual Sam
Updated on 25-Jun-2020 12:04:40
The Date object is a data type built into the JavaScript language. Date objects are created with the new Date( ) as shown below.Once a Date object is created, a number of methods allow you to operate on it. Most methods simply allow you to get and set the year, month, day, hour, minute, second, and millisecond fields of the object, using either local time or UTC (universal, or GMT) time.The toUTCString() function of the date object returns the UTCString of its date.SyntaxIts Syntax is as followsdateObj.toUTCString()Example Live Demo    JavaScript Example           var ... Read More

Date.toTimeString() function in JavaScript

karthikeya Boyini
Updated on 25-Jun-2020 12:05:15
The Date object is a data type built into the JavaScript language. Date objects are created with the new Date( ) as shown below.Once a Date object is created, a number of methods allow you to operate on it. Most methods simply allow you to get and set the year, month, day, hour, minute, second, and millisecond fields of the object, using either local time or UTC (universal, or GMT) time.The toTimeString() function of the date object returns the time in the date object.SyntaxIts Syntax is as followsdateObj.toTimeString()Example Live Demo    JavaScript Example           ... Read More
1 2 3 4 5 ... 70 Next
Advertisements