Javascript arrays

Beschreibung

A-Level Javascript Karteikarten am Javascript arrays, erstellt von James Drummond am 15/12/2015.
James Drummond
Karteikarten von James Drummond, aktualisiert more than 1 year ago
James Drummond
Erstellt von James Drummond vor fast 9 Jahre
21
1

Zusammenfassung der Ressource

Frage Antworten
How do you insert a character into a string in Javascript? Remember that Javascript strings are immutable var myStr = 'hi there'; var newString = myStr.subStr(0, i) + 'u' + myStr.subStr(i + 1);
How do you remove an item from the beginning of an array? var fruits = ["Apple", "Banana"]; fruits.shift();
How do you add an item to the beginning of an array? fruits.unshift('banana')
How do you find the index of an item in an array? var fruits = ["Apple", "Banana", "mango"]; var index = fruits.indexOf('mango');
How do you remove an item from an array? var pos = 1; var removedItem = fruits.splice(pos, 1); // Remove one item from position one
What does splice() do? Splice changes an array by removing elements and / or adding new ones
How would you remove two elements from a given index in an array? var arr = ['mango', 'banana', 'orange']; var removed = arr.splice(1, 2); // Removes two elements from the array starting at position 1
What is the difference between slice and splice? Slice returns a portion of an array. Splice modifies the array
How do you test if an object is an array? var myArr = []; Array.isArray(myArr) (IE9+) ** Note syntax. You don't call this on the array directly!**
How do you change a string to uppercase in Javascript? var newString = 'myString'.toUpperCase();
What does Array.map() do? The map method creates a new array with the results of performing a function on an old array.
What does Array.from() do? Creates a new array from an 'array like' or iterable object.
What does Array.reduce() do? Iterates the array and applies a function to the previously calculated and current value to reduce the array to a single value
What does Array.filter() do? Removes an item from an array (IE9 +)
Can you subclass an Array? You can in ES6, otherwise no.
Zusammenfassung anzeigen Zusammenfassung ausblenden

ähnlicher Inhalt

Quiz - Object Oriented Javascript
arunram.krish
Examen Fundamentos Basicos de Programación
Jose Valderrama0721
Test I. Introduction to web technologies
Angel Martínez Rodriguez
JavaScript Fundamentals
Andrew Watters
Front-End Web Development
Chanthy Ngin
Javascript - Quiz - Jan 2016
arunram.krish
OpenSource Programming
Faheem Ahmed
Javascript basics
James Drummond
jQuery Basics functions and method
Victor Bini
Javascript Variables
Rene Escobar
JavaScript DOM API - Funções Basicas - Interactive Web Pages
Victor Bini