Found 8862 Articles for Front End Technology

What is the use of Object.is() method in JavaScript?

vineeth.mariserla
Updated on 30-Jul-2019 22:30:26

138 Views

Object.is()Object.is() is used to check whether two values are same or not. Two values are same when they have the following criteria. Either both the values are undefined or null .Either both are true or false.Both strings should be of same length, same characters and in same order.The polarities of both the values should be equal.Both the values can be NaN and should be equal.syntaxObject.is(val1, val2);It accepts two parameters and scrutinize whether they are equal or not. If equal gives out true as output else false as output.There is a small difference between Object.is() and "==" that is when comparing +0 and -0, the former results false whereas the latter results true. ... Read More

How to add two strings with a space in first string in JavaScript?

vineeth.mariserla
Updated on 29-Jun-2020 11:10:23

5K+ Views

To add two strings we need a '+' operator to create some space between the strings, but when the first string itself has a space with in it, there is no need to assign space explicitly. In the following example since the string 'str1' has a space with in it, just only concatenation without space is adequate to add both the strings.ExampleLive Demo           function str(str1, str2) {          return (str1 + str2);       }       document.write(str("tutorix is the best ", "e-learning platform"));     Outputtutorix is the best ... Read More

How to parse an URL in JavaScript?

vineeth.mariserla
Updated on 30-Jul-2019 22:30:26

294 Views

Parsing an URLIt is very simple to parse an URL in javascript by using DOM method rather than Regular expressions. If regular expressions are used then code will be much more complicated. In DOM method just a function call will return the parsed URL. In the following example, initially a function is created and then an anchor tag "a" is created inside it using a DOM method. Later on the provided URL was assigned to the anchor tag using href. Now, when function returns the parts of the URL, it tries to return the parsed parts as shown in the output. ... Read More

How to decode an encoded string in JavaScript?

vineeth.mariserla
Updated on 30-Jul-2019 22:30:26

10K+ Views

DecodingIn JavaScript, to decode a string unescape() method is used. This method takes a string, which is encoded by escape() method, and decodes it. The hexadecimal characters in a string will be replaced by the actual characters they represent using unescape() method.Syntaxunescape(string)ExampleIn the following the two exclamation marks have converted to hexadecimal characters using escape() method. Later on those marks were decoded in to their natural characters using unescape() method. Live Demo    // Special character encoded with escape function    var str = escape("Tutorialspoint!!");    document.write("");    document.write("Encoded : " + str);    // unescape() function    document.write("Decoded ... Read More

How to remove non-word characters in JavaScript?

vineeth.mariserla
Updated on 30-Jul-2019 22:30:26

258 Views

Removing non-word charactersTo remove non-word characters we need to use regular expressions. The logic behind removing non-word characters is that just replace the non-word characters with nothing('').ExampleIn the following example there are many non-word characters and in between them there exists a text named "Tutorix is the best e-learning platform". So using regular expressions the non-word characters were replaced with nothing('') so as to get the word characters as the output.Live Demo    function remNonWord (string) {       if ((string===null) || (string===''))       return false;       else       string = ... Read More

What is the use of weakSet.has() method in JavaScript?

vineeth.mariserla
Updated on 29-Jun-2020 09:49:47

108 Views

weakSet.has()This is an inbuilt function in javascript which is used to return a boolean value on scrutinizing whether an object is present in weakSet or not. The weakSet object lets you store weakly held objects in a collection.SyntaxweakSet.has(obj);ArgumentsFrom the above line of code,  weakSet.has() accepts a parameter 'obj' and checks whether the parameter is present in the provided weakSet or not.Returning valueBased on presence of value, whether it is in weakSet or not, the weakSet.has() method returns a boolean output. If the value is present then true will be returned else false will be returned.Example-1In the following example weakSet.has() checks whether the object(user provided) 'object1' is ... Read More

HTML DOM Object type Property

Ankith Reddy
Updated on 30-Jul-2019 22:30:26

117 Views

The HTML DOM Object type Property is used to set or return the value of the type attribute of an object. However, the type attribute is used to set the media type like the object.Following is the syntax to set the type property −obj.type = type_of_mediaAbove, type_of_media is the standard media type, for example, image/bmp, image/tiff, image/tff, etc.Following is the syntax to return the type property −obj.typeLet us now see an example to implement the DOM Object type property −Example Live Demo Display the media type function display() {    var x = document.getElementById("obj").type;     ... Read More

Adding YouTube videos on an HTML web page

George John
Updated on 24-Nov-2023 01:36:49

822 Views

Videos can be easily from YouTube to your web page. You need to just embed the videos. At first, get the Video id − Step1: Go to the Video and right click on it. Select “Stats for nerds” − On clicking, you will get the following dialog box displaying the stats − Above you can see the video id is F6m0ghjadlw. Now, we will embed the same video using its id − Example    Learn WordPress    WordPress Installation    Following is the video demonstrating how to install WordPress on localhost ... Read More

HTML Doctypes

Chandu yadav
Updated on 30-Jul-2019 22:30:26

106 Views

Whenever you create an HTML document, the doctype is the first thing placed in the document.It conveys the web browser about the version of the HTML, this page is written on. It is not casesensitive.Let us see an example displaying DOCTYPE on the top −Example Live Demo Document Title comes here    Demo Heading    This is the demo text. OutputNow let us see some of the declarations for doctype −HTML5 DeclarationExampleHTML 4 StrictThis document type includes all HTML elements except those that have been deprecated, and those that appear in frameset documents.HTML 4 ... Read More

HTML DOM Anchor hash Property

Arjun Thakur
Updated on 30-Jul-2019 22:30:26

115 Views

The HTML DOM Anchor hash property is used to set or return the anchor part of the href attribute value. The part of the URL after the # is what we call the anchor part of a link.Following is the syntax to set the hash property −anchorObject.hash = anchor_partAbove, anchor_part is the anchor part of the URL.Following is the syntax to return the hash property −anchorObject.hashLet us now see an example to implement the DOM Anchor hash property −Example Live Demo Company Our Team Get the anchor part... Display Anchor Part    function display() {     ... Read More

Advertisements