Front End Technology Articles - Page 506 of 860

HTML File Paths

AmitDiwan
Updated on 19-Sep-2019 11:59:13

380 Views

File path in a website is the location of a file in that website. This path might be relative (in reference to current path) or absolute (full URL of file).SyntaxFollowing is the syntax:1) Relative pathsrc="ImgFolder/picture.jpg"Orsrc="../ImgFolder/picture.jpg"Orsrc="/ImgFolder/picture.jpg"2) Absolute pathsrc="http://www.tutorialspoint.com/html5/foo.mp4"Let us see an example of HTML DOM Video src property−Example Live Demo HTML DOM Video src    * {       padding: 2px;       margin:5px;    }    form {       width:70%;       margin: 0 auto;       text-align: center;    }    input[type="button"] {       border-radius: 10px;    } ... Read More

HTML Entities

AmitDiwan
Updated on 19-Sep-2019 11:45:39

188 Views

In HTML, some characters are reserved for syntax declaration. Using these characters in text might cause unwanted errors. For example, you cannot use the greater than and less than signs or angle brackets within your HTML text because the browser will treat them differently and will try to draw a meaning related to HTML tag.NOTE  − Entity names are case sensitive so should be used as they are.SyntaxFollowing is the syntax:&entity_nameOr&#entity_numberFollowing are some of the useful entities:ResultDescriptionEntity NameEntity Numbergreater than>>&ersand&&"double quotation mark""'single quotation mark (apostrophe)'$£Pound££¥Yen¥¥€Euro€€©Copyright©©®registered trademark®®Read More

How to free up the memory in JavaScript?

Ayush Gupta
Updated on 19-Sep-2019 08:31:03

2K+ Views

Regardless of the programming language, memory life cycle is pretty much always the same −Allocate the memory you needUse the allocated memory (read, write)Release the allocated memory when it is not needed anymoreThe second part is explicit in all languages. Use of allocated memory needs to be done by the developer.The first and last parts are explicit in low-level languages like C but are mostly implicit in high-level languages like JavaScript.Hence there is no explicit way to allocate or free up memory in JavaScript. Just initializing objects allocates memory for them. When the variable goes out of scope, it is ... Read More

How to allocate memory in Javascript?

Ayush Gupta
Updated on 19-Sep-2019 08:28:25

550 Views

Regardless of the programming language, memory life cycle is pretty much always the same −Allocate the memory you needUse the allocated memory (read, write)Release the allocated memory when it is not needed anymoreThe second part is explicit in all languages. Use of allocated memory needs to be done by the developer.The first and last parts are explicit in low-level languages like C but are mostly implicit in high-level languages like JavaScript.Hence there is no explicit way to allocate or free up memory in JavaScript. Just initializing objects allocates memory for them. When the variable goes out of scope, it is ... Read More

Explain the event flow process in Javascript

Ayush Gupta
Updated on 19-Sep-2019 08:21:34

812 Views

In the JavaScript, Event Flow process is completed by three concepts −Event Target − The actual DOM object on which the event occured.Event Bubbling − Explained belowEvent Capturing − Explained belowEvent bubbling is the order in which event handlers are called when one element is nested inside a second element, and both elements have registered a listener for the same event (a click, for example). With bubbling, the event is first captured and handled by the innermost element and then propagated to outer elements.With capturing, the event is first captured by the outermost element and propagated to the inner elements.Let's ... Read More

Name some of the string methods in javascript?

Ayush Gupta
Updated on 19-Sep-2019 07:37:38

300 Views

The String object lets you work with a series of characters; it wraps Javascript's string primitive data type with a number of helper methods. As JavaScript automatically converts between string primitives and String objects, you can call any of the helper methods of the String object on a string primitive.Following are some of the methods available for strings in JavaScript −concat() −Combines the text of two strings and returns a new string.indexOf() −Returns the index within the calling String object of the first occurrence of the specified value, or -1 if not found.lastIndexOf() −Returns the index within the calling String ... Read More

Write the usage of split() method in javascript?

Ayush Gupta
Updated on 19-Sep-2019 07:33:18

258 Views

The split([separator, [limit]]) method splits a String object into an array of strings by separating the string into substrings, using a specified separator string to determine where to make each split.Example usage of split methodlet a = "hello, hi, bonjour, namaste"; let greetings = a.split(', '); console.log(greetings)Output[ 'hello', 'hi', 'bonjour', 'namaste' ]Note that the commas were removed here. Any separator provided will be removed.If separator is an empty string, str is converted to an array having one element for each character of str.Examplelet a = "hello"; console.log(a.split(""))Output[ 'h', 'e', 'l', 'l', 'o' ]If no separator is provided, the string is ... Read More

How to Create GUID / UUID in JavaScript?

Arnab Chakraborty
Updated on 04-Apr-2023 11:21:05

12K+ Views

The Globally Unique Identifier (GUID) or (Universally Unique Identifier) is a 16-byte or 128- bit binary value that is used as an identifier standard for software construction. This 128-bit number is represented in a human-readable format by using the canonical format of hexadecimal strings. One example is like: de305d84-75c4-431d-acc2-eb6b0e5f6014. In this article, we shall cover how we can use javascript functionality to generate GUID or UUID. There are a few different methods, covered one by one: By using random number generation Example function generate_uuidv4() { return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) { ... Read More

How to convert a string to camel case in JavaScript?

Ayush Gupta
Updated on 19-Sep-2019 07:15:02

1K+ Views

Camel case is the practice of writing phrases such that each word or abbreviation in the middle of the phrase begins with a capital letter, with no intervening spaces or punctuation. For example, Concurrent hash maps in camel case would be written as −ConcurrentHashMapsWe can implement a method to accept a string in JavaScript to convert it to camel case in the following way −Examplefunction camelize(str) {    // Split the string at all space characters    return str.split(' ')       // get rid of any extra spaces using trim       .map(a => a.trim())     ... Read More

Why is using “for…in” with array iteration a bad idea in javascript?

Ayush Gupta
Updated on 19-Sep-2019 06:57:52

161 Views

Using for..in loops in JavaScript with array iteration is a bad idea because of the following behavior −Using normal iteration loops −Examplelet arr = [] arr[4] = 5 for (let i = 0; i < arr.length; i ++) {    console.log(arr[i]) }Outputundefined undefined undefined undefined 5If we had iterated over this array using the for in construct, we'd have gotten −Examplelet arr = [] arr[4] = 5 for (let i in arr) {    console.log(arr[i]) }Output5Note that the length of the array is 5, but this still iterates over only one value in the array.This happens because the purpose of ... Read More

Advertisements