Rules for JavaScript's Automatic Semicolon Insertion (ASI)

Amit Sharma
Updated on 13-Jun-2020 06:43:18

367 Views

JavaScript’s automatic semicolon insertion (ASI) is to insert missing semicolons. The following statements are affected by automatic semicolon insertion −empty statement var statement expression statement do-while statement continue statement break statement return statement  throw statementThe rules are in the following specification −When, as a Script or Module is parsed from left to right: A token is encountered that is not allowed by any production of the grammar, then a semicolon is automatically inserted before the offending token only if one or more of the following conditions becomes true −Offending token is }.Previous token is ) and the inserted semicolon would ... Read More

Methods in jQuery to Manipulate Attributes

Alex Onsman
Updated on 13-Jun-2020 06:41:35

170 Views

jQuery comes with a lot of methods to manipulate attributes. These are DOM related methods. The attributes include,text() – This method sets or returns the text content of elements selected.html() – This method sets or returns the content of elements selected.val() – This method sets or returns the value of form fields.You can try to run the following code to learn how to manipulate attributes with text() and html() methods −Example $(document).ready(function(){    $("#button1").click(function(){      alert("Using text- " + $("#demo").text());    });    $("#button2").click(function(){      alert("Using html()- " + $("#demo").html());    }); }); This is demo text. Text HTML

Disable Resizable Property of Textarea Using JavaScript

Rahul Sharma
Updated on 13-Jun-2020 06:39:07

242 Views

To disable resizable property, use CSS style −textarea {    resize: none; }To disable specific textarea with different attribute values, try the following. Let’s say the attribute is set to “demo” −textarea[name=demo] {    resize: none; }Let’s say the id attribute is “demo” −For the above,#demo {    resize: none; }

Handle Situations When JavaScript is Turned Off

Johar Ali
Updated on 13-Jun-2020 06:37:30

169 Views

Nowadays, almost every web browser supports JavaScript. If it is turned off, you can use tag. To let users know about non-JavaScript web browsers, use the tag. The HTML tag is used to handle the browsers, which do recognize tag but do not support scripting. This tag is used to display an alternate text message.Example           HTML noscript Tag                                              Your browser does not support JavaScript!          

Difference Between re.search and re.findall Methods in Python Regular Expressions

Rajendra Dharmkar
Updated on 13-Jun-2020 06:35:06

1K+ Views

The re.search() method is similar to re.match() but it doesn’t limit us to find matches at the beginning of the string only. Exampleimport re result = re.search(r'Tutorials', 'TP Tutorials Point TP') print result.group()OutputTutorialsHere you can see that, search() method is able to find a pattern from any position of the string.The re.findall() helps to get a list of all matching patterns. It searches from start or end of the given string. If we use method findall to search for a pattern in a given string it will return all occurrences of the pattern. While searching a pattern, it is recommended to ... Read More

Declare Variables in JavaScript

Rahul Sharma
Updated on 13-Jun-2020 06:32:51

1K+ Views

Like many other programming languages, JavaScript has variables. Variables can be thought of as named containers. You can place data into these containers and then refer to the data simply by naming the container.Before you use a variable in a JavaScript program, you must declare it. Variables are declared with the var keyword as follows.     You can also declare multiple variables with the same var keyword as follows −     Storing a value in a variable is called variable initialization. You can do variable initialization at the time of variable creation or at a later point in ... Read More

Where to Place the Google Analytics Tracking Code

Johar Ali
Updated on 13-Jun-2020 06:27:36

134 Views

When integrating your website with Google Analytics, add the Tracking Code in your code. This will allow Google Analytics to track the page views and provide other analytics.Copy the code and place it just before closing tag i.e. in your website code. When you will integrate, the following steps and the tracking code will be visible. This shows how and where to add the tracking code −

Place JavaScript in External Files

Amit Sharma
Updated on 13-Jun-2020 06:21:49

389 Views

To place JavaScript in external file create an external JavaScript file with the extension .js. After creating, add it to the HTML file in the script tag. The src attribute is used to include that external JavaScript file.If you have more than one external JavaScript file, then add it to the same web page to increase the performance of the page.Let’s say the following new.js is our external JavaScript file −function display() {    alert("Hello World!"); }Now add the external JavaScript file to the HTML web page −                                      

What Does Mean in a Python Regular Expression

Rajendra Dharmkar
Updated on 13-Jun-2020 06:20:09

2K+ Views

Non capturing groupsIf  we do not want a group to capture its match, we can write this regular expression as Set(?:Value). The question mark and the colon after the opening parenthesis are the syntax that creates a non-capturing group. The regex Set(Value)? matches Set or SetValue. In the first case, the first (and only) capturing group remains empty. In the second case, the first capturing group matches Value. The question mark appearing at the end is the quantifier that makes the previous token optional. Set(?:Value) matches Setxxxxx, i.e., all those strings starting with Set but not followed by Value. Such would be ... Read More

Difference Between Anonymous and Inline Functions in JavaScript

Rahul Sharma
Updated on 13-Jun-2020 06:18:52

2K+ Views

Anonymous FunctionsAnonymous, as the name suggests, allows creating a function without any names identifier. It can be used as an argument to other functions. This is how JavaScript anonymous functions can be used −var myfunc = function() {    alert(‘This is anonymous'); }Another example can be the following −setTimeout(function() {    alert('Demo'); }, 3000);Inline FunctionsAn inline function is a javascript function, which is assigned to a variable created at runtime. You can difference Inline Functions easily with Anonymous since an inline function is assigned to a variable and can be easily reused.This is how JavaScript inline functions can be used −var ... Read More

Advertisements