javascript get element into view when clicked code example

Example 1: javascript scrollintoview

var element = document.getElementById("box");

element.scrollIntoView();
element.scrollIntoView(false);
element.scrollIntoView({block: "end"});
element.scrollIntoView({behavior: "smooth", block: "end", inline: "nearest"});

Example 2: how to scroll through an object js

// Requiring the lodash library 
// console:  npm i --save lodash
const _ = require("lodash")

// Use of _.forEach() method

_.forEach({ 'a': 1, 'b': 2 }, function(value, key) {
  console.log(key)
})

Tags:

Misc Example