Understanding Undefined in JavaScript

AmitDiwan
Updated on 17-Jul-2020 07:19:59

294 Views

The JavaScript undefined property specifies if a variable has been declared or assigned a value yet.Following is the code implementing 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 age;   ... Read More

Template Strings in JavaScript

AmitDiwan
Updated on 17-Jul-2020 07:16:35

530 Views

Template were introduced in ES6 to allow embed expressions inside a string. Instead of ‘’ or “” quotation marks they use the backticks (``). They offer a much better way of string interpolation and expressions can be embedded in a way like ${a+b}. It offers a much nicer syntax than the + operator.Following is the code for template strings 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

Escape Characters in JavaScript

AmitDiwan
Updated on 17-Jul-2020 07:12:58

9K+ Views

Escape characters are characters that can be interpreted in some alternate way then what we intended to. To print these characters as it is, include backslash ‘\’ in front of them. Following are the escape characters in JavaScript −CodeResult\bBackspace\fForm FeedNew Line\rCarriage Return\tHorizontal Tabulator\vVertical Tabulator\'Single quote\"Double quote\BackslashFollowing is the code implement escape character Backslash in javaScript −Example Live Demo Document    body {       font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;    }    .result {       font-size: 18px;       font-weight: 500;    } Escape characters in JavaScript ... Read More

JavaScript Primitive and Object Types in Functions

AmitDiwan
Updated on 16-Jul-2020 14:01:21

228 Views

Following is the code to pass JavaScript primitive and object types to function −Example Live Demo Document    body {       font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;    }    .result {       font-size: 18px;       font-weight: 500;       color: blueviolet;    } Passing primitive/object types to function Click here Click on the above button to pass primitive and object to a function and call it    let BtnEle = document.querySelector(".Btn");    let resEle = document.querySelector(".result");    let person = { ... Read More

InnerHTML vs InnerText in JavaScript

AmitDiwan
Updated on 16-Jul-2020 13:55:22

1K+ Views

innerHTML − The innerHTML property returns the text, including all spacing and inner element tags. It preserves the formatting of the text and all the extra tags like , etc.innerText − The innerText property returns just the text, removing the spacing and the inner element tags.Following is the code for innerHTML and innerText in JavaScript −Example Live Demo Document    body {       font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;    }    .result,    .sample {       font-size: 18px;       font-weight: 500;       color: red;   ... Read More

Undeclared vs Undefined in JavaScript

AmitDiwan
Updated on 16-Jul-2020 13:52:48

1K+ Views

Undeclared − It occurs when a variable which hasn’t been declared using var, let or const is being tried to access.Undefined − It occurs when a variable has been declared using var, let or const but isn’t given a value.Following is the code for undeclared and undefined in JavaScript −Example Live Demo Document    body {       font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;    }    .result {       font-size: 18px;       font-weight: 500;       color: blueviolet;    } Undeclared vs Undefined ... Read More

Validate File Size in JavaScript While Uploading

AmitDiwan
Updated on 16-Jul-2020 13:51:30

976 Views

Following is the code for validating a file size in JavaScript while uploading −Example Live Demo Document    body {       font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;    }    .result {       font-size: 18px;       font-weight: 500;       color: blueviolet;    } Validating a file size while uploading Upload a file using the above file input type    let BtnEle = document.querySelector(".Btn");    let resEle = document.querySelector(".result");    let fileEle = document.querySelector(".file");    function validateFile() {       if ... Read More

Higher Order Arrow Functions in JavaScript

AmitDiwan
Updated on 16-Jul-2020 13:40:12

373 Views

JavaScript treats functions as objects and allow us to pass functions as parameter to another function and even return functions from other functions. In JavaScript, the functions are first class functions i.e. we can store them in variable, objects and array. The higher order arrow functions can take function, return them or do both.Following is the code for higher order arrow functions in JavaScript −Example Live Demo Document    body {       font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;    }    .result,    .sample {       font-size: 18px;       ... Read More

Disabling Arrow Key in Text Area using JavaScript

AmitDiwan
Updated on 16-Jul-2020 13:35:40

321 Views

Following is the code for disabling arrow key in text area in JavaScript −Example Live Demo Document    body {       font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;    }    .result {       font-weight: 500;       font-size: 18px;       color: blueviolet;    } Disabling arrow keys in a text area Hello world this is some sample text inside the text area element Disable arrows Click on the above button to disable scrolling using arrows in the above textArea    let ... Read More

Setting Full Screen Iframe in JavaScript

AmitDiwan
Updated on 16-Jul-2020 13:33:03

2K+ Views

Following is the code for setting full screen iframe in JavaScript −Example Live Demo Document    body {       font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;    }    .result {       font-weight: 500;       font-size: 18px;       color: blueviolet;    }    .fullScreen {       width: 100vw;       height: 100vh;    } Setting full screen iframe Fullscreen Click on the above button to make the iframe go fullscreen    let BtnEle = document.querySelector(".Btn");    let frameEle = document.querySelector(".frame");    BtnEle.addEventListener("click", () => {       frameEle.className = "fullScreen";    }); OutputOn clicking the ‘Fullscreen’ button −

Advertisements