Posts tagged 'java script'
In javascript, What is the difference between let and var?
In JavaScript, "let" and "var" are both used for declaring variables, but they have some differences in how they work and how they can be used.
What is lexical scope in javascript?
In JavaScript, lexical scope means that a variable defined outside a function can be accessed by another function defined after the variable declaration. On the other hand, variables defined inside a function are not accessible outside of it.
How to get current url in javascript
Javascript provides multiple methods to get current url which is displayed in the browser address bar and all these methods relies on window.location.
Get string between parentheses or brackets
We can easily get the string between parentheses or brackets using regular expression. This regular expression can be applied in any programming language / scripts like php, javascript,java,perl,python,c#,asp etc.
Call function from string in javascript without eval
Lets say, we grabed a function call from somewhere and have it in a variable, Simply match the function name and parameters separately using regular expression and call the function using window object.
Regex check minimum and maximum length
Using Regular expression( Regex ), We can check whether the given string has minimum no. of characters or whether it is inside specified range etc.
Replace string in javascript
Generally, "replace" method in java script replaces only the first occurrence in the given string. We can change this behaviour by using regular expression.