Javascript Array Push Error
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss .push is not a function javascript the workings and policies of this site About Us Learn more about push is not a function jquery Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow push is not a function angularjs Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each uncaught typeerror: push is not a function other. Join them; it only takes a minute: Sign up javascript array push error in Safari Browser up vote 1 down vote favorite I got this error SyntaxError: Unexpected token '}'. Expected a ':' following the property name 'value'. (anonymous function) when doing this : var datas1 = []; angular.forEach(data.data, function(value, key) { if(value.comfi_type_id == "1" || value.comfi_type_id
Uncaught Typeerror: .push Is Not A Function
== "3" || value.comfi_type_id == "4") datas1.push({value}) }) $timeout(function() { $scope.items = {'data':{'data1':datas1}}; }, 1000); The code run fine on Chrome, but only Safari appeared to be error. Can anyone enlighten me, what is wrong? Question Update After I doing this datas1.push({value:value}) It is now run fine in Safari browser. But now when I tried on ios device (this is ionic app) the code is not functioning. No data is push inside datas1 I thought when everything work on Safari, also work on ios device ? javascript safari share|improve this question edited Aug 6 '15 at 15:37 asked Aug 6 '15 at 15:11 Azizi 3371316 add a comment| 2 Answers 2 active oldest votes up vote 3 down vote accepted Safari probably doesn't support the short object notation ({ value }). You have to specify the key and the value: datas1.push({ value: value }); share|improve this answer answered Aug 6 '15 at 15:18 Razem 1,11146 That's great, it is working now. Will mark as answer later :) –Azizi Aug 6 '1
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us
.push Is Not A Function Angularjs
Learn more about Stack Overflow the company Business Learn more about hiring developers uncaught typeerror data push is not a function or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack javascript push undefined is not a function Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Javascript: array.push is undefined up vote 0 http://stackoverflow.com/questions/31859452/javascript-array-push-error-in-safari-browser down vote favorite I have my code: var name = []; var mark1 = []; var mark2 = []; var mark3 = []; var total = []; count = 0 count2 = 0 var i = 0; while (count != 2) { var nam = prompt("Enter name:") name.push(nam); var mk1 = prompt("Enter mark 1:"); var mk1 = parseInt(mk1); mark1.push(mk1); var mk2 = prompt("Enter mark 2:"); var mk2 http://stackoverflow.com/questions/27092688/javascript-array-push-is-undefined = parseInt(mk2); mark2.push(mk2); var mk3 = prompt("Enter mark 2:"); var mk3 = parseInt(mk3); mark3.push(mk3); var tot = mk1 + mk2 + mk3; total.push(tot) count = count + 1 console.log(mk1 + mk2 + mk3); console.log(nam); console.log("the count is " + count) }; When I run it I get an error: Uncaught TypeError: undefined is not a function on Line 12 which is name.push(nam); I have looked around but I am not sure what I am doing wrong. Help appreciated. javascript arrays share|improve this question edited Nov 23 '14 at 18:38 CD.. 41.2k1888117 asked Nov 23 '14 at 18:32 crablab 156 I can't reproduce that error with your code. –Quentin Nov 23 '14 at 18:34 one important thing when asking for help is to make sure your code's properly indented. Humans like to be able to read things easily. Another is to confirm that's really what's going wrong. If we drop this code into jsbin.com or jsfiddle.net, it works just fine –Mike 'Pomax' Kamermans Nov 23 '14 at 18:35 no errors thrown here: jsfiddle.net/6yjwh1a5 –BeNdErR Nov 23 '14 at 18:35 1 @BeNdErR your link wraps the code in a function, protecting the identifier confl
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or http://stackoverflow.com/questions/14257709/push-is-not-a-function-javascript-error posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Push is not a function JavaScript error up vote 3 down vote favorite In the below code, I am getting "push is not a function" error. Can anyone please let me know what I am doing is not wrong here? I am trying to create 2D array in Javascript. var myArray = new Array(4); myArray = ["0","0","0","0"]; for (var i=0; i