Member-only story
jQuery — Iteration, Requests, and Objects
jQuery is a popular JavaScript for creating dynamic web pages.
In this article, we’ll look at how to using jQuery in our web apps.
jQuery.each()
We can iterate over objects, arrays, and array-like objects with the length
property with the each
method.
For example, if we have:
$.each([52, 97], function(index, value) {
console.log(index, value);
});
Then we log the index
and value
for each entry in the array.
jQuery.escapeSelector()
We can escape any character that has special meaning in a CSS selector with the escapeSelector
method.
For example, we can write:
console.log($.escapeSelector( "#target" ))
to return the escaped string.
So we see:
'\#target'
logged.
jQuery.extend()
The jQuery.extend()
method lets us merge 2 or more objects together into the first object.
For example, we can write:
const object1 = {
apple: 0,
banana: {
weight: 52,
price: 100
},
cherry: 97
};
const object2 = {…