Posts

Showing posts with the label Javascript

Difference between jQuery parent() and parents() method?

Image
The basic difference is the parent() function travels only one level in the DOM tree, where parents() function search through the whole DOM tree. To understand this, let's look at the below-given HTML code. When you make a call to parent() function like $("#spnText").parent() It will give you "P" as the output.parent() function selects the first parent in the DOM tree. Now,if we call parents() function like $("#spnText").parents() It will give all parents in DOM tree which are, p->dvChild->dvParent->form-> body->html. You can pass a filter in parents() function  as well to select specific parent like if you want to select both the divs then $("#spnText").parents('div');

List of JavaScript object method

Methods Description concat() It returns a new array object that contains two or more merged arrays. copywithin() It copies the part of the given array with its own elements and returns the modified array. every() It determines whether all the elements of an array are satisfying the provided function conditions. fill() It fills elements into an array with static values. filter() It returns the new array containing the elements that pass the provided function conditions. find() It returns the value of the first element in the given array that satisfies the specified condition. findIndex() It returns the index value of the first element in the given array that satisfies the specified condition. forEach() It invokes the provided function once for each element of an array. includes() It checks whether the given array contains the specified element. indexOf() It searches the specified element in the given array

What are life cycle hooks in VueJs?

beforeCreate -  The first component in the creation of hooks. This allows us to perform actions before our component has been added to DOM. We don't have access to DOM inside of this hook. Created  -This hook is invoked when Vue has set up events and data observations. Here, events are active and access to reactive data is enabled through templates that have not yet been mounted or rendered. beforeMount -  The beforeMount hooks runs right before the initial render happens and after the template or render functions have complied. Mounted  - This is a most used hook and you will have full access to the reactive component, templates, and rendered DOM (via. this.$el). The most frequently used patterns are fetching data for your component. beforeUpdate -  This hook runs after data changes on our component and the update cycle begins. But it runs right before the DOM is patched and re-renders. Updated  - This hook runs after data changes on your component and the DOM re-renders.

List of JavaScript array method

Methods Description concat() It returns a new array object that contains two or more merged arrays. copywithin() It copies the part of the given array with its own elements and returns the modified array. every() It determines whether all the elements of an array are satisfying the provided function conditions. fill() It fills elements into an array with static values. filter() It returns the new array containing the elements that pass the provided function conditions. find() It returns the value of the first element in the given array that satisfies the specified condition. findIndex() It returns the index value of the first element in the given array that satisfies the specified condition. forEach() It invokes the provided function once for each element of an array. includes() It checks whether the given array contains the specified element. indexOf() It searches the specified element in the given array