The disabled attribute of the element is used to disable element. When an element is disabled, it becomes unclickable. For obvious reasons, the disabled input element won’t get submitted.SyntaxFollowing is the syntax −Let us now see an example to implement the disabled attribute of the element −Example Live Demo Details These are the new details... New Details: Player: Rank: Email: Reporting Time: OutputThis will produce the following output wherein we have disabled one of the input element “Player” −In the above example, we have four fields −Player: ... Read More
Block ElementsThe block elements appear on a screen as if they have a line break before and after them. They also take up the entire available width. Some of the block elements include, to , , , , , , , , etc.ExampleLet us see an example of one of the block element , , , etc − Live Demo Coding Ground Compilers for Programming Languages and Web Technologies Click on the individual links to work on online compilers: Java | PHP | jQuery | C | C++ | AngularJS We also have complier for JS ... Read More
Web Garden is the web hosting system which comprises of multiple “processes”. This means that we have a single server on which we run multiple processes. This type of hosting provides logical scalability to our web applications.Web Farm is the web hosting system which comprises of multiple “computers”. This is different from web-garden as web garden runs on a single server while a web farm runs across multiple servers. This provides physical scalability to out web applications. This type of set up is achieved using Load balancers to balance calls coming to the server using a dedicated process that forwards ... Read More
The parseInt function available in JavaScript has the following signature −parseInt(string, radix);Where, the paramters are the following −String − The value to parse. If this argument is not a string, then it is converted to one using the ToString method. Leading whitespace in this argument is ignored.Radix − An integer between 2 and 36 that represents the radix (the base in mathematical numeral systems) of the string.So we can pass the string and the radix and convert any numbner with base from 2 to 36 to integer using this method.Exampleconsole.log(parseInt("100", 10)) console.log(parseInt("10", 8)) console.log(parseInt("101", 2)) console.log(parseInt("2FF3", 16)) console.log(parseInt("ZZ", 36))Output100 8 ... Read More
This is not a feature of JavaScript but is Chrome's way of displaying uninitialized indexes in arrays (and array-like objects). For example, if you console.log the following −Exampleconsole.log(Array(100))Output[undefined × 100]This is better than printing [undefined, undefined, undefined,...] as it is more readable.
JavaScript allows you to add very advanced features to your web applications. For example, Drawing and manipulating graphicsAudio and Video APIs like HTMLMediaElement, the Web Audio API, and WebRTC allow you to do really interesting things with multimedia such as creating custom UI controls for playing audio and video, displaying text tracks like captions and subtitles along with your videos, grabbing video from your web camera to be manipulated via a canvas (see above) or displayed on someone else's computer in a web conference, or adding effects to audio tracks (such as gain, distortion, panning, etc).Device APIs are basically APIs ... Read More
According to MDN, An arrow function expression is a syntactically compact alternative to a regular function expression, although without its own bindings to the this, arguments, super, or new.target keywords. Arrow function expressions are ill suited as methods, and they cannot be used as constructors.There are 3 subtle differences in regular functions and arrow functions in JavaScript.No own this bindingsArrow functions do not have their own this value. The value of this inside an arrow function is always inherited from the enclosing scope.Examplethis.a = 100; let arrowFunc = () => {this.a = 150}; function regFunc() { this.a = 200; ... Read More
Javascript arrays are 0-indexed. This means that the first element is at the 0th position. The last element is at the length-of-array - 1th position. So we can access these elements using −Examplearr[0] // First element arr[arr.length - 1] // last element For example, let arr = [1, 'test', {}, 'hello'] console.log(arr[0]) console.log(arr[arr.length - 1])Output1 hello
Javascript specification doesn't specify a particular algorithm to be used in the Array.sort implementation. This is left on the implementor to decide. So different JS engines use different sorting algorithms.Mozilla(Spider Monkey JS engine) uses mergeSort. You can see the code written for it in C in the Mozilla repository: https://dxr.mozilla.org/seamonkey/source/js/src/jsarray.cWebKit(Chrome, Safari, etc) do not directly use a sorting algorithm, instead they choose the algorithm based on element types and length of the array. For example, Numeric arrays use C++ Std library's quick sort function.Non-numeric arrays use merge sort.In some other cases it uses selection sort.It depends on the datatype and ... Read More
The unshift method adds the element at the zeroeth index and shifts the values at consecutive indexes up, then returns the length of the array.The push() method adds the element at end to an array and returns that element. This method changes the length of the array.Examplelet fruits = ['apple', 'mango', 'orange', 'kiwi']; let fruits2 = ['apple', 'mango', 'orange', 'kiwi']; console.log(fruits.push("pinapple")) console.log(fruits2.unshift("pinapple")) console.log(fruits) console.log(fruits2)Output5 5 [ 'apple', 'mango', 'orange', 'kiwi', 'pinapple' ] [ 'pinapple', 'apple', 'mango', 'orange', 'kiwi' ]Note that both the original arrays were changed here.Unshift is slower than push because it also needs to unshift all the elements ... Read More