JavaScript Generator

AmitDiwan
Updated on 08-May-2020 11:30:08

379 Views

A generator function uses the yield keyword to generate results and maintain its state even after returning so that the next time when it is called it can resume immediately from the last yield run. Each call to the generator function will send a value back to the caller.Following is the code for the Generator function in JavaScript −Example Live Demo Document    body {       font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;    }    .sample {       font-size: 18px;       font-weight: 500;    } JavaScript ... Read More

Best Tutorial Sites to Learn HTML

Nikitha N
Updated on 08-May-2020 11:13:35

200 Views

HTML stands for Hyper Text Markup Language, which is the most widely used language on Web to develop web pages. HTML was created by Berners-Lee in late 1991 but "HTML 2.0" was the first standard HTML specification which was published in 1995. HTML 4.01 was a major version of HTML and it was published in late 1999. However, HTML 4.01 version is widely used but currently we are having HTML-5 version, which is an extension to HTML 4.01, and this version published in 2012.To learn HTML, refer HTML tutorial. It explains the below given HTML concepts perfectly:HTML Basic TagsElementsAttributesHTML Phrase ... Read More

JavaScript DataView

AmitDiwan
Updated on 08-May-2020 11:09:35

203 Views

The JavaScript DataView allows us for reading and writing in multiple number types in binary ArrayBuffer by providing a low level interface. We cannot manipulate ArrayBuffer directly without using DataView().Following is the code for implementing JavaScript DataView −Example Live Demo Document    body {       font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;    }    .sample {       font-size: 20px;       font-weight: 500;    } JavaScript DataView() CLICK HERE Click on the above button to change the array buffer contents using DataView()   ... Read More

Difference Between Height and Line Height

Alex Onsman
Updated on 08-May-2020 11:06:32

3K+ Views

Height is the vertical measurement of the container, for example, height of a div.Line-height is a CSS property to specify the line height i.e. the distance from the top of the first line of text to the top of the second. It is the space between the lines of two paragraphs.ExampleYou can try to run the following code to learn the difference between height and line height:Live Demo                    .height {             height: 20px;          }          .lheight ... Read More

JavaScript Cursor Property

AmitDiwan
Updated on 08-May-2020 11:05:17

212 Views

The cursor property is sets or returns the cursor type that will be displayed for the cursor property.Following is the code for implementing JavaScript Cursor property −Example Live Demo    body {       font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;    } JavaScript Cursor property Hover the mouse over the above paragraph after clicking the below button Change Cursor    let sampleEle = document.querySelector(".sample");    document.querySelector(".Btn").addEventListener("click", () => {       sampleEle.style.cursor = "crosshair"; }); OutputOn clicking the “Change Cursor” button −

JavaScript Array.from() Method

AmitDiwan
Updated on 08-May-2020 10:59:07

164 Views

The Array.from() creates a new array object from a given array instance.Following is the code for the array from() function −Example Live Demo Document    body {       font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;    }    .sample {       font-size: 20px;       font-weight: 500;    } JavaScript Array from() example CLICK HERE Click on the above button to create the array from given string    let fillEle = document.querySelector(".sample");    let arr = "HelloWorld";    fillEle.innerHTML = arr;    document.querySelector(".Btn").addEventListener("click", () => {       fillEle.innerHTML = Array.from(arr);    }); OutputOn clicking the “CLICK HERE” button the string will convert into array as follows −

Array findIndex Function in JavaScript

AmitDiwan
Updated on 08-May-2020 10:46:54

1K+ Views

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

JavaScript Array isArray Method

AmitDiwan
Updated on 08-May-2020 10:41:18

162 Views

The JavaScript Array.isArray() method is used to check if an object is an array or not.Following is the code for the Array.isArray() method −Example Live Demo Document    body {       font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;    }    .sample {       font-size: 20px;       font-weight: 500;    } JavaScript Array isArray() CLICK HERE Click on the above button to check if the above object is an array or not    let fillEle = document.querySelector(".sample");    let arr = ["cow", "bull", ... Read More

JavaScript Array includes Method

AmitDiwan
Updated on 08-May-2020 10:37:45

160 Views

The JavaScript array.includes() method is used to check if an array contains a given element or not.Following is the code for the array.includes() method −Example Live Demo Document    body {       font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;    }    .sample {       font-size: 20px;       font-weight: 500;    } JavaScript Array includes() CLICK HERE Click on the above button to check if the array contains lion element or not    let fillEle = document.querySelector(".sample");    let arr = ["cow", "bull", "lion", "tiger", "sheep"];    fillEle.innerHTML = arr;    document.querySelector(".Btn").addEventListener("click", () => {       fillEle.innerHTML = "Lion is present in array: " + arr.includes("lion");    }); OutputOn clicking the “CLICK HERE” button −

JavaScript Focus Method

AmitDiwan
Updated on 07-May-2020 15:04:05

550 Views

The JavaScript focus() method is used for focusing on an element only if the element can be focused.Following is the code for the JavaScript Focus() Method −Example Live Demo Document    body {       font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;    }    .sample {       font-size: 18px;       font-weight: 500;    } JavaScript focus() CLICK HERE Click on the above buttons to focus the input field    let sampleEle = document.querySelector(".sample");    document.querySelector(".Btn").addEventListener("click", () => {       sampleEle.focus();    }); OutputOn clicking the “CLICK HERE” button −

Advertisements