Showing posts with label JavaScript. Show all posts
Showing posts with label JavaScript. Show all posts

Monday, January 26, 2026

Javascript DEBUG functions

 

 

Object.entries(obj)
const obj = { foo: "bar", baz: 42 };
console.log(Object.entries(obj)); // [ ['foo', 'bar'], ['baz', 42] ]
 
const obj = { foo: "bar", baz: 42 };
const map = new Map(Object.entries(obj));
console.log(map); // Map(2) {"foo" => "bar", "baz" => 42}
// Using for...of loop
const obj = { a: 5, b: 7, c: 9 };
for (const [key, value] of Object.entries(obj)) {
  console.log(`${key} ${value}`); // "a 5", "b 7", "c 9"
}

// Using array methods
Object.entries(obj).forEach(([key, value]) => {
  console.log(`${key} ${value}`); // "a 5", "b 7", "c 9"
});
  
const object = {
a: 1,
b: 2,
c: 3,
};

console.log(Object.getOwnPropertyNames(object));
// Expected output: Array ["a", "b", "c"]
 
  
const object1 = {
  a: 'somestring',
  b: 42,
  c: false
};

console.log(Object.values(object1));
// Expected output: ["somestring", 42, false]

 

 

 

References:

[1] https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/entries

[2] https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyNames

 

Friday, July 26, 2019

Interactive Maps and D3 and others


References:
[1] Image to map by Deep Learning https://ai.facebook.com/blog/mapping-roads-through-deep-learning-and-weakly-supervised-training/

Resources

[1] Just a map https://codepen.io/manishgolcha/post/world-map-using-d3-js
[2] Datamaps http://datamaps.github.io/
     Tutorial https://github.com/markmarkoh/datamaps/blob/master/README.md#getting-started

[3] Worldmap by cuntry tooltip http://bl.ocks.org/micahstubbs/8e15870eb432a21f0bc4d3d527b2d14f
[4] d3-zoom https://github.com/d3/d3-zoom


Free geocode
[1] Works using open street map https://opencagedata.com/api
      https://api.opencagedata.com/geocode/v1/json?q=São Paulo&key=8c0e3ccc191e41f38dd211fe50fb9eab

[2] Limited https://developer.here.com/documentation/maps/dev_guide/topics/quick-start.html

[3] Google not recommended https://developers.google.com/maps/documentation/geocoding/intro


Testing
https://blockbuilder.org/Ayumix01/984d70d411ea1d29f48b3963881a5618
 https://medium.com/@ttemplier/map-visualization-of-open-data-with-d3-part3-db98e8b346b3
http://datawanderings.com/2018/10/28/making-a-map-in-d3-js-v-5/
https://github.com/ivan-ha/d3-hk-map



Wednesday, May 18, 2011

JavaScript::Add Extensions

Array.prototype.newMethod = function () {

return “this is an extended method for javascript array”;

};http://www.blogger.com/img/blank.gif

var js_array = new Array();

alert(js_array.newMethod());


references:
[1] Extend array functions http://blog.programmingsolution.net/javascript/javascript-array-extension/
[2] http://stackoverflow.com/questions/477700/array-functions-in-jquery

Javascript DEBUG functions

    Object . entries ( obj ) const obj = { foo : "bar" , baz : 42 } ; console . log ( Object . entries ( obj ) ) ; // [ [...