Tagged Questions
0
votes
1answer
13 views
AngularJS - passing variable to function returns preprocessed syntax
I want to send an AngularJS variable to a function in my controller. Here's a sample snippet of my code:
<ul>
<li ng-repeat="score in scores | filter:search | orderBy : 'first'">
...
0
votes
3answers
28 views
alternate defining method in javascript [duplicate]
When should I use such syntax to define a function in JavaScript
myfunc = myfunc ||
function(n){
return this.length;
};
instead of
myfunc =
function(n){
return this.length;
...
0
votes
2answers
14 views
jQuery's Request To Javascript Function
Okay so look at these to alert()s. Here is the full code:
function OfficialFacebookLikes(Title)
{
$.getJSON('https://graph.facebook.com/'+Title, function(data) {
...
0
votes
1answer
26 views
Issue with for loop with sqlite data insertion
I need to insert 5 rows where only one column values gets changed and remaining are same in all rows.
var Category1_fr ="one";
var Category2_fr ="one";
var Category3_fr ="one";
var Category4_fr ...
0
votes
2answers
67 views
Javascript function calling syntax
(function($,window,undefined) {
$.fn.simplyScroll = function(options) {
return this.each(function() {
new $.simplyScroll(this,options);
});
};
var defaults = ...
3
votes
3answers
44 views
What is the valid Javascript syntax for creating an object by using Object Literal Notation?
I'm learning Javascript track in codecademy.com. And I'm confused about creating object by using "Object Literal Notation".
Here syntax1, in the hint section the syntax is:
var friends = {
bill: ...
0
votes
3answers
38 views
what does exclamation mark mean before selector
as in the title
i know already that the exclamation mark is used generally to express negation
like "no", "not", "null" in javascript.
but what i want to know is what the exclamation mark does before ...
0
votes
0answers
38 views
If and else if loop syntax or logic
$('.listing-img').each(function(){
$temp = $(this);
image_url = $(this).attr('src');
$section_content = $('.main_wrapper').find('section');
...
0
votes
3answers
39 views
variable declaration conditional syntax
I was looking some great d3.js code examples when I saw something like:
var links = [
{source: "test1", target: "test2"},
{source: "test1", target: "test3"},
{source: "test2", target: "test3"},
...
0
votes
0answers
7 views
Using Alex Gorbatchev's Syntax Higlighter in a GitHub wiki
I have been using the pages on Blogger for the documentation of my programming language (http://zettalanguage.blogspot.co.uk) but I would now like to transition over to GitHub. The only thing is that ...
6
votes
6answers
156 views
What's the meaning of “=>” in JavaScript?
I know that ">=" operator means more than or equal to, but I've seen "=>" from a source code. What's the meaning of that operator?
Here's the code:
promiseTargetFile(fpParams, aSkipPrompt, ...
0
votes
1answer
28 views
Javascript 'case' vs “case” [duplicate]
I'm learning about switches in Javascript, and whenever I add a case, I'm not sure whether to use single quotation marks or double quotation marks.
switch(answer)
{
case 'hello':
...
0
votes
1answer
12 views
Javascript syntax : Nested callback
I would like to know if there is a way to write the following code quicker.
items.getAll() callback has to take the same arguments as database.query() callback. So I just would like to "rethrow" the ...
0
votes
1answer
62 views
jQuery .first-child syntax
As a beginner I struggle with the jQuery syntax.
I realize that the following code is NOT selecting the first-child (the div).
My question:
Why is the syntax wrong and how should I select the div in ...
0
votes
1answer
11 views
Trouble working out whether one attribute of an object is greater that another attribute of that object
I am comparing two attributes of the same object to work out which one is larger, if one is larger then it sets another attribute to True.. else it sets it to false.
Here is my function:
...
1
vote
2answers
42 views
Why does moving the start of the comment down one line of whitespace break compilation of this JavaScript code in WordPress?
I'm having to use WordPress for this particular page, and I wouldn't put it past WordPress to have a bug here, but maybe it is just the JavaScript. Why does this compile:
var pData = ...
4
votes
3answers
37 views
Bitshift Operator Used on Object in Javascript
I've been trying to teach myself Javascript lately and I'm noticing several slightly quirky syntax choices used by various different authors. Usually I can figure them out, but this one's stumped me a ...
0
votes
1answer
23 views
Syntax Error - missing before statement [closed]
Hello I tried to run this javascript in iMacros:
macro += "VERSION BUILD=7601105 RECORDER=FX" + "\n";
macro += "SET !ERRORIGNORE YES"
macro += "URL GOTO=http://siteadress.com/index.html" + "\n";
...
0
votes
1answer
10 views
Javascript multiple comparison expressions syntax
By gut-feeling I know the following to be wrong syntax, or at least not working as intended (tried it), but there is no error thrown either:
var x = 2;
if (1 < x < 3) ...
I guess the VM ...
0
votes
0answers
24 views
trouble updating jQuery to more recent version
I am trying to update the jQuery version from 1.7 to a 1.11, but I am having trouble with the syntax for selecting elements on an html page with specific criteria. This syntax worked with 1.7, but ...
-4
votes
3answers
31 views
JSLint error The '&&' subexpression should be wrapped in parens ? OR with IF conditions error [duplicate]
JSLint gives me the following error :
The '&&' subexpression should be wrapped in parens.
Here is the line which causes problem:
if (anchorLink === 'page1' || anchorLink === 'page2' || ...
1
vote
2answers
33 views
Confusion on jasmine / Angular Test syntax
I am starting out with Angular and Jasmin tests and following the angular tutorial and this code is set for the test:
describe('PhoneListCtrl', function(){
beforeEach(module('phonecatApp'));
...
0
votes
1answer
33 views
Conditional expressions instead of if statement [duplicate]
As I understand
b && "" !== b && (a[b] = this);
is just the same as
if(b && "" !== b)
a[b] = this;
Are these syntax forms equivalent?
1
vote
2answers
57 views
Syntax Highlighter HTML solution [closed]
I am trying to use
http://alexgorbatchev.com/SyntaxHighlighter/
And dont want to have to always insert my code between the pre tags in the index.html.
I have tried making a text area and using java ...
0
votes
1answer
21 views
Double data binding with angularjs controller as style
I am searching how to use double data-binding in angularjs respecting controller as style recommended by Google. It looks like:
hello.mainpage.HomeCtrl = function() {
/**
* @type {string}
* ...
0
votes
2answers
22 views
Shorthand way to check for function parameters
In my code, I have a function that creates a new map given a few parameters. I want to make it so that if no parameters are passed, some default values will be used.
Why won't this work:
function ...
0
votes
1answer
39 views
Angular.js “Controller As” on templateUrl/template ng-click/blur/focus events not working?
I know this has to be a simple thing I'm overlooking, but google is not being my friend right now.
When using the "controllerAs" syntax, for some reason if I use it for an element within a template, ...
0
votes
2answers
22 views
Avoid comma expressions and duplicate declerations
In order to clear up my code I have been paying attention to all of the hints in Web Storm. The following duplicate declaration errors have confused me.
In the following code, is the double use of ...
2
votes
1answer
52 views
Why does this JavaScript nonsense alert “fail”? [duplicate]
I realize that this is intended as a joke, but someone posted this and it alerts "fail" in the browser, what is going on that makes this happen?
...
-3
votes
1answer
41 views
js syntax errors in text adventure
hi i'm new to java script and I wrote a text adventure for a school project and I keep getting these error when I try to run it
js: "adventure.js", line 4: missing ( before condition
js: if var ...
0
votes
0answers
31 views
javascript Bracket notation syntax [duplicate]
Is there a better way to write that :
var modifier = {};
modifier[rowId + '.' + columnName] = value;
I can't use the following as it only accepts a constant for the first part.
modifier = { rowId ...
0
votes
2answers
44 views
function syntax is semicolon really needed here
JSHint keeps telling me that this is incorrect.
this.x = function( z ) {do stuff}
it is reporting there should be a semicolon before the last }
this.x = function( z ) {do stuff;}
and lint is ...
0
votes
1answer
24 views
Pound “” is not geeting display in html page? [duplicate]
i am trying to display a pound sign in my html page.i want to display it through a variable because i am getting the values of sign from an xml file.
Here is Code:
<div ...
0
votes
1answer
22 views
How does Emberjs seemingly extend Javascript's syntax?
How does Emberjs accomplish the following syntax in Javascript?
var handler = function(){
console.log('Triggered');
}.on('someEvent');
The part of interest is the .on('whatever'). I get errors ...
1
vote
0answers
49 views
Differences between Object Oriented JavaScript and Java? [closed]
I am trying to understand some of the differences between writing Object-Oriented Java and Object-Oriented JavaScript. I have a fair amount of experience in Java, but not much experience with ...
1
vote
1answer
22 views
AngularJS $resource - Call the method via a variable?
I have an Angular $resource as
var Client = $resource('/api/clients/:id',{id : '@id'}, {
query: { method: 'GET' })
I want to be able to call, say query() or save() via a ...
0
votes
2answers
45 views
Why won't false become true?
I am working on a game, and for some reason these click functions are not permanently changing the top values to true, I use console log to test it, and the bottom log always says false. I know this ...
-1
votes
2answers
39 views
Javascript Syntax Error - if/else statement
this is my first question so apologies if my issue is not clearly displayed. I'm getting error messages with the 'else' part of the if/else statement. About half-way down the code I've commented on ...
0
votes
2answers
35 views
Explain the following JavaScript syntax: var fib = require('algorithms.js').Math.fibonacci;
I'm having trouble understanding how the following code makes sense:
var fib = require('algorithms.js').Math.fibonacci;
I see this is storing 'algorithms.js' in a var named fib but what does the ...
0
votes
0answers
28 views
Possible syntax error while loading video via jQuery
I am trying to call two functions using one link: change the link of a youtube video and show its description.
<a href="#" class="videoLink" data-video="ylLzyHk54Z0" data-description="This is a ...
0
votes
1answer
22 views
Does the @ and ` symbols have any use in JavaScript?
I've become quite familiar with JavaScript variable naming conventions and operators and have noticed that pretty much every ASCII character on my keyboard has some sort of use as part of a variable ...
-2
votes
3answers
113 views
Call Method from Constructor: Error: Uncaught TypeError: undefined is not a function
Task: I need to build a class in Typescript that calls some of it's own methods in it's own Constructor.
Problem: The Actual Code that the following Sample Code represents will Compile Successfully, ...
0
votes
1answer
26 views
What does this javascript syntax / pattern mean? [duplicate]
I've seen this pattern in a code and I'm trying to understand what's the idea behind it
foo : {
//some code here
console.log('1');
}
foo is some html node, and console.log represents some ...
2
votes
4answers
39 views
Javascript variable declaration, why is this legal? [duplicate]
I just encountered this variable declaration syntax for the first time.
var myVar = (function() {
return 1;
})();
My 2 main questions are..
What is it called, and why is it legal?
Forgive me ...
-3
votes
4answers
58 views
How to get particular value form javascript associative array [duplicate]
HI i have a matrix aray like below
var pricemultiarray = {
"Coast-to-Coast": {
"1": ["10", "20", "30", "50", "60"],
"2": ["15", "30", "40", "60", "80"],
"3": ...
0
votes
0answers
22 views
What is wrong with the following coffeescript code
I'm very new to coffee-script. I kept getting the error:
error: unmatched OUTDENT
product = new Model2({
Here is the code:
describe 'Test case 1', ->
describe 'Method 1', ->
...
2
votes
3answers
79 views
Why is JavaScript designed to automatically insert a semicolon after a return followed by a new line?
I just ran into a problem where I did:
return
isSomething() &&
isSomethingElse();
which doesn't work because javascript inserts the semicolon after the return making the above ...
1
vote
1answer
39 views
How to specify float32 limits in JavaScript?
Kinda stupid question but I can't get this to compile in JavaScript:
var float_MaxValue = 3.40282347e+38F; // largest positive number in float32
var float_MinValue = -3.40282347e+38F; // largest ...
0
votes
0answers
33 views
Visual Studio 2013 not Syntax Checking js files
Visual Studio 2013 isn't verifying .js files.
I have a separate .js file under a Scripts folder, that is then referenced in my ASPX page.
The intellisense works when the script is within an html ...
2
votes
2answers
34 views
jQuery Pulling text from <li> to hidden form field
I know I'm making some simple mistake, I just can't seem to see it.
<li class="ui-state-default" id="1">Text I want to pull</li>
$('#control1').prop('value', "test" ); //this ...