Tag: syntax

What's wrong in the code below?

I get a console error: ‘Uncaught SyntaxError: Unexpected token -‘ What’s wrong? Please, may anyone help? $(document).ready(function() { $(“#widget_settings_holder”).find(“.tbLanguageTabs”).first().tabs(); var cmpt-br = CodeMirror.fromTextArea(document.getElementById(“text_widget_text_pt-br”), { mode: “htmlmixed”, lineNumbers: true, tabMode: “indent” }); $(tbApp).off(“tbWidget:onUpdate.textWidget”).one(“tbWidget:onUpdate.textWidget”, function(event, $widget, $form) { if ($widget.attr(“id”).split(“_”)[1] != “HtmlWidget”) { return; } cmpt-br.toTextArea(); $form.find(“textarea[name$='[text]’]”).each(function() { $(this).val(utf8_to_b64($(this).val())); }); }); });

What does this Javascript syntax mean? function () { http: var a = 2; }

I was just looking through some code from a few days ago and I noticed this snippet: function getTextWidth(text, font) { http: //stackoverflow.com/a/21015393/1413853 var canvas = getTextWidth.canvas || (getTextWidth.canvas = document .createElement(“canvas”)); var context = canvas.getContext(“2d”); context.font = font; var metrics = context.measureText(text); return metrics.width; } Notice the line: http: //stackoverflow.com/a/21015393/1413853 Which should actually be […]

Using & (bitwise AND operator) in Angular ng-if expressions

I can’t get the & operator to work in an Angular ng-if expression (to use with some bit flags). Suppose we have some HTML like this: <div ng-if=”value & 2″> </div> If value equals 3, then the bitwise operation should return 2 and thus a true value. However, Angular throws a Syntax Error exception every […]

Why doesn't this for loop work when I simple change two expression's order

This question already has an answer here: es6 array desctructuring weirdness 4 answers

What is this 'method-like' syntax in JS object literal

This question already has an answer here: How does this object method definition work without the “function” keyword? 2 answers

Javascript variable initialization syntax

I’m working with a javascript (Ext JS 4) project, and I came across this: { init: function() { var me = this, desktopCfg; … } } What exactly is being assigned to ‘me’ in this situation?

Quotation marks in PHP / JS / DOM

What is the right way to use quotation marks ? echo ‘string’ . $variable . ‘anotherstring’; or echo “string” . $variable . “anotherstring”; the problem of course comes to light when we need to print, return, or echo the quotaion mrk itself … $output = ‘<div class=”‘ . $class . ‘ ” style =” ‘ […]

Strange javascript syntax

anybody can help me with the following Js syntax? I don’t understand the line starting with “( $.inArray( wzdId, this….” I mean why does that line start with just a parentesis? What does it mean? This is the complete code: _activateStep: function( wzdId ) { if ( condition ) { var stepIndex = this._findNav( wzdId […]

JavaScript syntax madness: pointer to eval function is not the eval function?

The following needs to be in function scope, since the strange behavior does not occur is interactive console mode. Following function returns 5 as expected (function() { var x = 5; return eval(“x”); })() A simple transparent(ish) change: (function() { var x = 5; var j = eval; return j(“x”); })() yields an error: ReferenceError: […]

Javascript, getElementById and style not working: Uncaught TypeError: Cannot read property 'style' of null

I have this code here: document.getElementById(‘success’).style.display(“block”); document.getElementById(‘success’).text(“aaaa”); and I get this error, why? Uncaught TypeError: Cannot read property ‘style’ of null <span id=”success” style=”color:#FFF; display:none;”></span> I moved my code to bottom of the page and I get this new error now Uncaught TypeError: Property ‘display’ of object #<CSSStyleDeclaration> is not a function