Tutorial by Examples

Git provides multiple commands for listing branches. All commands use the function of git branch, which will provide a list of a certain branches, depending on which options are put on the command line. Git will if possible, indicate the currently selected branch with a star next to it. GoalCommand...
HTML: <div class="wrapper"> <div class="left-sidebar"> <h1>Left Sidebar</h1> <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. </p> </div> <div class="content"> <h1>Content</h1&g...
The JSON.parse() method parses a string as JSON and returns a JavaScript primitive, array or object: const array = JSON.parse('[1, 2, "c", "d", {"e": false}]'); console.log(array); // logs: [1, 2, "c", "d", {e: false}]
A JavaScript value can be converted to a JSON string using the JSON.stringify function. JSON.stringify(value[, replacer[, space]]) value The value to convert to a JSON string. /* Boolean */ JSON.stringify(true) // 'true' /* Number */ JSON.stringify(12) // '12...
A replacer function can be used to filter or transform values being serialized. const userRecords = [ {name: "Joe", points: 14.9, level: 31.5}, {name: "Jane", points: 35.5, level: 74.4}, {name: "Jacob", points: 18.5, level: 41.2}, {name: "Jessie",...
A reviver function can be used to filter or transform the value being parsed. 5.1 var jsonString = '[{"name":"John","score":51},{"name":"Jack","score":17}]'; var data = JSON.parse(jsonString, function reviver(key, value) { return ke...
You can use a custom toJSON method and reviver function to transmit instances of your own class in JSON. If an object has a toJSON method, its result will be serialized instead of the object itself. 6 function Car(color, speed) { this.color = color; this.speed = speed; } Car.prototype.to...
JavaScript has two primary ways to represent binary data in the browser. ArrayBuffers/TypedArrays contain mutable (though still fixed-length) binary data which you can directly manipulate. Blobs contain immutable binary data which can only be accessed through the asynchronous File interface. Conver...
DataViews provide methods to read and write individual values from an ArrayBuffer, instead of viewing the entire thing as an array of a single type. Here we set two bytes individually then interpret them together as a 16-bit unsigned integer, first big-endian then little-endian. var buffer = new Ar...
var data = 'iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACN' + 'byblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHx' + 'gljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg=='; var characters = atob(data); var array = new Uint8Array(characters.length); for (var i = 0; i < characters.length; i++) { array[i] ...
TypedArrays are a set of types providing different views into fixed-length mutable binary ArrayBuffers. For the most part, they act like Arrays that coerce all assigned values to a given numeric type. You can pass an ArrayBuffer instance to a TypedArray constructor to create a new view of its data. ...
5.1 When you take a reference to a method (a property which is a function) in JavaScript, it usually doesn't remember the object it was originally attached to. If the method needs to refer to that object as this it won't be able to, and calling it will probably cause a crash. You can use the .bind...
Template literals are a special type of string literal that can be used instead of the standard '...' or "...". They are declared by quoting the string with backticks instead of the standard single or double quotes: `...`. Template literals can contain line breaks and arbitrary expression...
The String.raw tag function can be used with template literals to access a version of their contents without interpreting any backslash escape sequences. String.raw`\n` will contain a backslash and the lowercase letter n, while `\n` or '\n' would contain a single newline character instead. const p...
A function identified immediately before a template literal is used to interpret it, in what is called a tagged template literal. The tag function can return a string, but it can also return any other type of value. The first argument to the tag function, strings, is an Array of each constant piece...
Inheritance in Python is based on similar ideas used in other object oriented languages like Java, C++ etc. A new class can be derived from an existing class as follows. class BaseClass(object): pass class DerivedClass(BaseClass): pass The BaseClass is the already existing (parent)...
Instance variables are unique for each instance, while class variables are shared by all instances. class C: x = 2 # class variable def __init__(self, y): self.y = y # instance variable C.x # 2 C.y # AttributeError: type object 'C' has no attribute 'y' c1 = C(3) c1....
The idea of bound and unbound methods was removed in Python 3. In Python 3 when you declare a method within a class, you are using a def keyword, thus creating a function object. This is a regular function, and the surrounding class works as its namespace. In the following example we declare method ...
Python 2.x2.2.0 New-style classes were introduced in Python 2.2 to unify classes and types. They inherit from the top-level object type. A new-style class is a user-defined type, and is very similar to built-in types. # new-style class class New(object): pass # new-style instance new = N...
if [[ $1 -eq 1 ]]; then echo "1 was passed in the first parameter" elif [[ $1 -gt 2 ]]; then echo "2 was not passed in the first parameter" else echo "The first parameter was not 1 and is not more than 2." fi The closing fi is necessary, but the eli...

Page 51 of 1336