parent
c70ee5c5f3
commit
aee10fac37
5 changed files with 67 additions and 0 deletions
@ -0,0 +1,8 @@ |
||||
You can use `getBoundingClientRect` method to get the dimensions of an element. |
||||
|
||||
```js |
||||
const roadmapWrapper = document.querySelector('.roadmap-wrapper'); |
||||
const dimensions = roadmapWrapper.getBoundingClientRect(); |
||||
|
||||
console.log(dimensions); // DOMRect { x: 8, y: 8, width: 784, height: 784, top: 8, right: 792, bottom: 792, left: 8 } |
||||
``` |
@ -0,0 +1,25 @@ |
||||
Yes, you can merge multiple arrays into one array using the `concat()` method, or the spread operator `...`. |
||||
|
||||
## concat() |
||||
|
||||
The `concat()` method is used to merge two or more arrays. This method does not change the existing arrays, but instead returns a new array. |
||||
|
||||
```js |
||||
const arr1 = [1, 2, 3]; |
||||
const arr2 = [4, 5, 6]; |
||||
|
||||
const arr3 = arr1.concat(arr2); |
||||
console.log(arr3); // [1, 2, 3, 4, 5, 6] |
||||
``` |
||||
|
||||
## Spread operator |
||||
|
||||
The spread operator `...` is used to expand an iterable object into the list of arguments. |
||||
|
||||
```js |
||||
const arr1 = [1, 2, 3]; |
||||
const arr2 = [4, 5, 6]; |
||||
|
||||
const arr3 = [...arr1, ...arr2]; |
||||
console.log(arr3); // [1, 2, 3, 4, 5, 6] |
||||
``` |
@ -0,0 +1,9 @@ |
||||
To remove a DOM element, you can use the `remove` or `removeChild` method of the `Node` interface. |
||||
|
||||
```js |
||||
const roadmapWrapper = document.querySelector('.roadmap-wrapper'); |
||||
const roadmapTitle = document.querySelector('#roadmap-title'); |
||||
|
||||
roadmapWrapper.removeChild(roadmapTitle); |
||||
roadmapWrapper.remove(); |
||||
``` |
@ -0,0 +1,5 @@ |
||||
In order to scroll to the top of the page, we can use the `scrollTo` method. |
||||
|
||||
```js |
||||
window.scrollTo(0, 0); |
||||
``` |
Loading…
Reference in new issue