Dev/javascript
-
array shuffle ( array random )Dev/javascript 2016. 5. 26. 15:00
function shuffle(array) { var copy = [], n = array.length, i; // While there remain elements to shuffle… while (n) { // Pick a remaining element… i = Math.floor(Math.random() * n--); // And move it to the new array. copy.push(array.splice(i, 1)[0]); } return copy;} 출처 : https://bost.ocks.org/mike/shuffle/
-
-
javascript eval()Dev/javascript 2012. 3. 9. 16:44
var jsonstr = "{"list":[{"path_id":"1|3|4","node_type":"o","path_txt":"포스코|테스트2|테스트2-1","id":"4","ddtime":null,"level":"3","name":"테스트2-1","seq":"1","user_id":"0","comment":"테스트2-1설명","dflag":"n","udtime":null,"parent_id":"3","cdtime":"2012-03-09 14:27:10.0"}],"exist":true}"; var obj = eval("nObj = "+replaceAll(jsonstr, """, '"')); alert( obj.list[0].name );