JavaScript unescape() Function with Example

AmitDiwan
Updated on 12-May-2020 06:11:52

269 Views

The JavaScript unescape() function is used to decode an encoded string. It is deprecated in JavaScript version 1.5.Following is the code for the unescape() function −Example Live Demo Document    body {       font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;    }    .sample,    .result {       font-size: 18px;       font-weight: 500;       color: red;    }    .result {       color: blueviolet;    } JavaScript unescape() property CLICK HERE CLICK the above button to decode the above url ... Read More

JavaScript Undefined Property

AmitDiwan
Updated on 12-May-2020 06:09:36

197 Views

The JavaScript undefined property specifies if a variable has been declared or assigned a value yet.Following is the code for the JavaScript undefined property −Example Live Demo Document    body {       font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;    }    .sample {       font-size: 18px;       font-weight: 500;       color: red;    } JavaScript undefined property CLICK HERE CLICK the above button to know if variable age has been defined or not    let sampleEle = document.querySelector(".sample");    let ... Read More

Understanding 'this' Identifier in JavaScript

AmitDiwan
Updated on 12-May-2020 06:04:05

222 Views

The JavaScript this keyword refernces the object to which it belongs. It can refer to the global object if alone or inside a function. It refers to the owner object if inside a method and refers to the HTML element that received the event in an event listener.Following is the code for the JavaScript this Identifier −Example Live Demo Document    body {       font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;    }    .sample {       font-size: 18px;       font-weight: 500;       color: red;    } ... Read More

JavaScript Source Property

AmitDiwan
Updated on 12-May-2020 05:52:30

166 Views

The JavaScript source property returns the regexp text against which a given pattern is to matched.Following is the code for the source property −Example Live Demo Document    body {       font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;    }    .sample,    .result {       font-size: 18px;       font-weight: 500;       color: red;    }    .result {       color: rebeccapurple;    } JavaScript source property The king bought a ring CLICK HERE Click on the above button to get the regex source text    let resultEle = document.querySelector(".result");    let pattern = /ing/gi;    document.querySelector(".Btn").addEventListener("click", () => {       resultEle.innerHTML = "Regexp text = " + pattern.source;    }); OutputOn clicking the ‘CLICK HERE’ button −

JavaScript Regular Expressions

AmitDiwan
Updated on 11-May-2020 14:36:01

463 Views

Regular expressions are a string of characters describing a search pattern. This search pattern is then used to specify what we are searching in a text.Following is the code for regular expressions in JavaScript −Example Live Demo Document    body {       font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;    }    .sample, .result{       font-size: 18px;       font-weight: 500;       color:red;    } JavaScript Regular Expressions The king bought the ring and went to the palace. CLICK HERE Click on the above ... Read More

JavaScript Random Number Generation

AmitDiwan
Updated on 11-May-2020 14:31:17

233 Views

The Math.random() function is used to generate a random floating-point number between 0 and 1.Following is the code for Math.random() function −Example Live Demo Document    body {       font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;    }    .sample {       font-size: 18px;       font-weight: 500;       color: red;    } JavaScript Random CLICK HERE Click on the above button to generate a random number between 1 to 10    let sampleEle = document.querySelector('.sample');    document.querySelector('.Btn').addEventListener('click',()=>{       let num = Math.floor((Math.random()*10))+1;       sampleEle.innerHTML = 'Number generated = ' + num;    }) OutputOn clicking the “CLICK HERE” button −

JavaScript Promises

AmitDiwan
Updated on 11-May-2020 14:13:06

1K+ Views

Promises in JavaScript allow us to do asynchronous operations where the value is not known in advanced when the promise was being created. A promise can have three states pending, fulfilled and rejected.Following is the code for promises in JavaScript −Example Live Demo Document    body {       font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;    }    .sample {       font-size: 18px;       font-weight: 500;       color: red;    } JavaScript Promises CLICK HERE Click on the above button to display username ... Read More

JavaScript Object Properties

AmitDiwan
Updated on 11-May-2020 14:07:18

234 Views

Properties in JavaScript are the values associated with an object. Following is the code implementing object properties in JavaScript −Example Live Demo Document    body {       font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;    }    .sample {       font-size: 18px;       font-weight: 500;       color: red;    } JavaScript Object Properties CLICK HERE Click on the above button to display name and age property from testObj object    let sampleEle = document.querySelector(".sample");    document.querySelector(".Btn").addEventListener("click", () => {       let testObj = { name: "Rohan",age: 23,};       sampleEle.innerHTML += "testObj.name = " + testObj.name + "";       sampleEle.innerHTML += "testObj.age = " + testObj.age + "";    }); OutputOn clicking the ‘CLICK HERE’ button −

JavaScript Object Accessors

AmitDiwan
Updated on 11-May-2020 13:55:31

197 Views

The getter and setter keyword are used for accessing the objects. The getter return value is used when a property is being accessed and the setter takes an argument and sets the property value inside the object to that passed argument.Following is the code for accessing objects in JavaScript −Example Live Demo Document    body {       font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;    }    .sample {       font-size: 18px;       font-weight: 500;       color: red;    } JavaScript Object Accessors Enter a ... Read More

JavaScript Numbers Example

AmitDiwan
Updated on 11-May-2020 13:51:46

165 Views

Following is an example for numbers in JavaScript −Example Live Demo Document    body {       font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;    }    .sample{       font-size: 18px;       font-weight: 500;       color: red;    } JavaScript Numbers CLICK HERE Click on the above button to see numbers in JavaScript    let sampleEle = document.querySelector(".sample");    let a =22;    let b = 1.523;    let c = 99;    document.querySelector(".Btn").addEventListener("click", () => {       sampleEle.innerHTML = 'a = ' + a + '';       sampleEle.innerHTML += 'b =' + b + '';       sampleEle.innerHTML += 'c = ' + c + '';       sampleEle.innerHTML += 'a + c = ' + (a+c) + '';    }); OutputOn clicking the ‘CLICK HERE’ button −

Advertisements