lang
stringclasses
4 values
desc
stringlengths
2
8.98k
code
stringlengths
7
36.2k
title
stringlengths
12
162
JS
First of all , I know how most RegExp questions go ; and this is not one of those , `` please write my code '' questions.My confusion lies in the fact that my RegExp works on regexr , and in chrome 's dev tools when polling the document.body.textContent , but not on an HTML file after I have read it in io.js.io.js is v...
fs.readFile ( 'view.html ' , { encoding : 'utf8 ' } , function ( error , html ) { console.log ( html.match ( myRegExp ) ) ; // null } ) ; < ! doctype html > < html > < head > < title > @ { title } < /title > < /head > < body > < h1 > @ { foo.bar } < /h1 > < p > Lorem ipsum dolor sit amet , @ { foo.baz.hoo } < /p > @ { ...
RegExp not working on read HTML file
JS
I am using jQuery Datatables and applying Individual column searching ( select inputs ) .On table footer I have a bootstrap-select where I can select multiple options and filter my data.It works fine but when I select option ( s ) I want to the other selects to be updated based on the previous selected options.So in my...
$ ( document ) .ready ( function ( ) { var table = $ ( ' # example ' ) .DataTable ( { initComplete : function ( ) { this.api ( ) .columns ( ) .every ( function ( ) { //for each column I add bootstrap selectpicker to the footervar column = this ; var select = $ ( ' < select class= '' form-control show-tick '' data-conta...
how to update select options based on previous selected values in jQuery DataTables
JS
Here is my HTML : As you can see I 've set unique names on the checkboxes to isolate them completely.formData follows a structure like this : The form populates correctly.Checkboxes are generated correctly , however , there is some odd behavior : When I click the checkbox for the first column , it also checks the box f...
< tr *ngFor= '' let row of formData ; let i = index '' [ attr.data-index ] = '' i '' > < td *ngFor= '' let rowdata of formData [ i ] ; let j = index '' [ attr.data-index ] = '' j '' > < input type= '' checkbox '' name= '' row- { { i } } - { { j } } '' [ ( ngModel ) ] = '' formData [ i ] [ j ] '' > < /td > < /tr > formD...
Updating input affects other input yet there is no binding
JS
The instanceof operator should look at the prototype , no ? Why does it not change its answer after the object 's prototype has been changed ? Example below :
// The .prototype of objects created with 'new MyKlass'// is MyKlass.prototypevar MyKlass = function ( name , age ) { this.name = name ; this.age = age ; } var xx = new MyKlass ( 'xx ' , 20 ) ; console.log ( xx instanceof MyKlass ) ; // true , OKxx.prototype = new String ( 's ' ) ; console.log ( xx instanceof MyKlass )...
why instanceof keeps saying true after prototype changed ?
JS
Consider this code : When I run it in Chrome and check in the console , b turns out to be of type DOMWindow , while c is of type klass . Although both have the property a , effectively both being an instance of klass . Is using or not using new , the same ? Is it the same on this example but different in other situatio...
function klass ( z ) { this.a = z ; return this ; } var b = klass ( 5 ) ; var c = new klass ( 9 ) ;
Is using new in Javascript the same as not using it ?
JS
Some minutes ago , while playing with javascript , I noticed a strange behaviour of console.log ( ) . In fact it seems to log `` distorted '' variables . Take a look to the following : It prints correct variables into # res but not into browser console ( Firefox 37 ) Could someone explain me why this happens ?
var res = document.getElementById ( `` res '' ) ; var arr = [ `` 1 '' , `` 2 '' , `` 3 '' ] ; arr.push ( `` 4 '' ) ; res.innerHTML = JSON.stringify ( arr ) + ' < br > ' ; console.log ( arr ) ; arr.push ( `` 5 '' ) ; res.innerHTML += JSON.stringify ( arr ) ; console.log ( arr ) ; < div id= '' res '' > < /div >
Strange behaviour of console.log ( ) on Firefox 37
JS
I have a default message on the top of a donation form and I would like it to change dynamically depending on which amount the user hovers or clicks . Each amount as well as `` €Other '' should have a corresponding message . For Example : `` with €5.00 we can accomplish this ... '' With €10.00 we could do that ... '' T...
< p > Choose below the amount of your donation < /p > < form action= '' https : //www.paypal.com/cgi-bin/webscr '' method= '' post '' target= '' _blank '' > < input type= '' hidden '' name= '' cmd '' value= '' _donations '' > < input type= '' hidden '' name= '' business '' value= '' louzanimalespaypal @ gmail.com '' > ...
How to swap text both on hover and onclick
JS
Update - JSFiddle demo here : https : //jsfiddle.net/vb2ptmuo/11/I 'm playing around with an interesting effect I came across : https : //tympanus.net/codrops/2019/08/07/image-trail-effects/To start , I have a div containing a bunch of img elements . It dumps them into an array and then creates a trail effect from thos...
< div class= '' content '' > < img src= '' 1.jpg '' > < img src= '' 2.jpg '' > < img src= '' 3.jpg '' > < /div > < div class= '' content-2 '' > < img src= '' 4.jpg '' > < img src= '' 5.jpg '' > < img src= '' 6.jpg '' > < /div >
Problem re-using a Class / Not understanding instantiation
JS
uhh it 's hard to come with a right title for this problem excuse me.In a backbone.js application i am building . Models , Views , Templates are all in separate javascript , html files . I want to export the Models , Views and Templates to the application bootstapper file ( app.js ) without polluting the global variabl...
window.App.Model.PersonModel = Backbone.Model.extend ( { } ) ; var instance = new window.App.Model.PersonModel ( ) ; var personView = new window.App.Views.PersonView ( { model : instance } ) ;
Exposing application scripts to certain scripts only
JS
I have this array : I need to turn it into this : How can I do this ? I figure I can do a million iterators to get the job done , but I think maybe there 's a cleaner way to do this.I 'm using Underscore and jQuery if that helps .
[ { name : 'email ' , value : ' a @ b.com ' } , { name : 'phone ' , value : '123-123-1234 ' } ] { email : ' a @ b.com ' , phone : '123-123-1234 ' }
Simple way to flatten this array ?
JS
Some jQuery methods expect a function as a parameter , but to work they should receive an anonymous function as a parameter rather than a function directly , as in the following example : rather than Consider retornaNada ( ) as a function without any body of code . Why can not we pass the function directly ?
$ ( `` a '' ) .on ( `` click '' , function ( ) { retornaNada ( ) ; } ) ; $ ( `` a '' ) .on ( `` click '' , retornaNada ( ) ) ;
Why should we use anonymous functions with jQuery instead of the function directly ?
JS
I 'm reviewing some html produced by an outside shop . They use comments inside their external script loading tags - so far as i 'm aware this was only useful for very old javascript unaware browsers is there any modern function for this or is it redundant ?
< script type= '' text/javascript '' src= '' path/to/file.js '' > < ! -- // -- > < /script >
Does < script > < ! -- // -- > < /script > have a modern purpose ?
JS
I have an array of strings that looks like this.I need somehow to place those strings in the following text by commas but before the last item instead of a comma , I need to set and . Something like this : 'Your card is including a white t-shirt , blue jeans , red hat and brown glasses you can go to checkout page'Since...
[ 'white t-shirt ' , 'blue jeans ' , 'red hat ' , 'brown glasses ' ... ]
How does one join string-type array-items , each with a comma character , except for the last item which has to be joined by `` and '' ?
JS
I have some geographic boundaries that I have a GeoJSON endpoint for . I also have some variables that are stored at a separate GeoJSON endpoint which does not have coordinates , but does have the variable that I want to later thematically style a map with later on with D3 . This is updated weekly.There is a common ID ...
// Load LGAs from ArcGIS Online ( The GeoJSON with geoms ) d3.json ( `` the url to the Geoms '' , function ( error , data ) { // Load Crash Stats from ArcGIS Online ( the total persons involved , summarised down to LGA names ) d3.json ( `` the url to the table '' , function ( error , data2 ) { var lga = data.features ;...
Joining GeoJSON to another GeoJSON
JS
I 'm experiencing rather weird behavior when trying to log a window object defined by $ window.open ( ) in AngularJS within an $ intervalOutputAs you can see , the first console.log $ scope.childWindow is outputting a fully defined window object . All others , inside the $ interval , are outputting only { } . I 've tri...
self = this $ scope.childWindow = $ window.open ( authService.buildAuthorizeUrl ( ) , '_blank ' ) console.log $ scope.childWindowvar1 = `` I may not work '' self.var2 = ' I should work'privateData.authInterval = $ interval - > console.log $ scope.childWindow console.log var1 console.log self.var2 , 1000 Window { docume...
Window object cleared on $ Interval
JS
Yesterday , we had no power at home , thus no Internet . So I assumed that I would n't be able to have my web-app work locally , since at the end of `` index.html '' I have : However , that was n't the case , it would work smoothly . So I guessed that the browser remembered the last time it downloaded these js files.Wh...
< script src= '' https : //ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js '' > < /script > < script > window.jQuery || document.write ( ' < script src= '' ../../assets/js/vendor/jquery.min.js '' > < \/script > ' ) < /script > < script src= '' http : //maxcdn.bootstrapcdn.com/bootstrap/3.3.1/js/bootstrap.min.j...
Understanding caching ?
JS
Consider this JavaScript function : I would expect that a and arguments [ 0 ] reference the same value only up to the second statement of the function . Instead they appear to always refer the same value : f ( 2 ) causesand f ( { foo : 'bar ' } ) causes : Are argument identifiers and the arguments identifier linked in ...
var f = function ( a ) { console.log ( a+ '' `` +arguments [ 0 ] ) ; a = 3 ; console.log ( a+ '' `` +arguments [ 0 ] ) ; } 2 23 3 [ object Object ] [ object Object ] 3 3
Arguments and reference
JS
I have a < div > ; it contains a < span > . When you click on the < div > , it removes the span , and replaces it with a < div > containing an < input > and a < button > . This is all well and good.The < button > , when clicked is supposed to remove its parent < div > ( the appended one ) and replace it with a < span >...
< div id= '' myPage '' > < div id= '' clickMe '' class= '' selectedField editMe '' > < span > Click Me < /span > < /div > < /div > $ ( function ( ) { $ ( ' # myPage ' ) .on ( 'click ' , '.selectedField ' , function ( ) { if ( $ ( this ) .hasClass ( 'editMe ' ) ) { var $ this = $ ( this ) .toggleClass ( 'editMe editing ...
Appended div is n't part of the DOM
JS
The code in question is simple : Why does foo ( ) execute , before it is defined ( retrospective edit : in Chrome and Safari ) ? I tinkered with this a bit , testing the following code in Chrome , Safari and Firefox : An alert is displayed in Chrome and Safari , while Firefox remains silent.Is there any explanation for...
console.log ( `` So it begins . `` ) ; foo ( ) ; function foo ( ) { console.log ( `` In foo ( ) . `` ) ; } console.log ( `` So it ends . `` ) ; javascript : foo ( ) ; function foo ( ) { alert ( `` Oh . `` ) ; }
What is the explanation of this behavior ? ( When are functions created ? )
JS
In the YUI documentation ; http : //yuilibrary.com/yui/docs/api/files/dom_js_dom-create.js.htmlLine 110 says that } else if ( nodes [ 0 ] & & nodes [ 0 ] .className === 'yui3-big-dummy ' ) { // using dummy node to preserve some attributes ( e.g . OPTION not selected ) What does this mean exactly ? I do n't understand w...
if ( nodes.length === 1 ) { // return single node , breaking parentNode ref from `` fragment '' ret = nodes [ 0 ] .parentNode.removeChild ( nodes [ 0 ] ) ; } else if ( nodes [ 0 ] & & nodes [ 0 ] .className === 'yui3-big-dummy ' ) { // using dummy node to preserve some attributes ( e.g . OPTION not selected ) if ( node...
Why does yui DOM-create method have a handler for the class named 'yui3-big-dummy ' ?
JS
I need to download a large ( > 100MB ) file of data via XmlHttpRequest . The data is from a third party and I would like to display the content gradually as it gets downloaded.So I thought the following would work : Sadly , according to the spec , .response is not available.Is there any way to access the already downlo...
var req = new XMLHttpRequest ( ) ; req.open ( `` GET '' , mirror.url , true ) ; req.responseType = `` arraybuffer '' ; req.onload = function ( oEvent ) { console.log ( `` DONE '' ) ; } ; var current_offset = 0 ; req.addEventListener ( `` progress '' , function ( event ) { if ( event.lengthComputable ) { var percentComp...
Accessing already downloaded data
JS
Let 's say I have this empty array : Here is the question : If I have data array that is filled with 6 objects like this : How can I populate the list array with the data of data array like this : I have used this for loop with no luck :
var list = [ ] ; var data = [ ] ; data [ 0 ] = { Name : `` Jack '' , accuracy : `` average '' , accent : 79 , weight : 1 } ; data [ 1 ] = { Name : `` Sara '' , accuracy : `` good '' , accent : 24 , weight : 2 } ; data [ 2 ] = { Name : `` Nick '' , accuracy : `` not bad '' , accent : 89 , weight : 1 } ; data [ 3 ] = { N...
Creating separate arrays into another array from data of an object
JS
Please consider the following snippet ( fiddle here ) : Why does the delete keywords behave differently on the global variables a and b ?
​var a ; ​a = 1 ; console.log ( delete a​ ) ; // prints 'false'​b = 1 ; console.log ( delete b ) ; ​ // prints 'true'​​​​
Different behaviour of delete keyword on global variables
JS
From within a function likeis there a reliable and efficient way to determine whether e is a DOM event ?
function eventHandler ( e ) { // ... }
Test whether an object is a DOM event
JS
I have to create reports based on the user input . User answer a question , and then depending on the answer I go left or right in a treelike structure , and ask a new question . Some nodes will have the same question , but different children . I am not sure what would be the best way to do it in terms of code readabil...
if ( ) { if ( ) { if ( ) { if ( ) { ... } } else { if ( ) { ... } } } else { ... } } else { if ( ) { if ( ) { if ( ) { ... } } else { if ( ) { ... } } } }
Optimising treelike control structure
JS
I 've tried following code in ie , firefox and node.jsthe results in browsers are 10 , 15 , but the result in node.js is undefined , 15.Please explain to me what is the different behavior of “ this ” keyword in browsers and node.js ? I 've read many pages but there was n't any obvious answer.Thanks in advance .
var x = 10 ; var o = { x : 15 } ; function f ( ) { console.log ( this.x ) ; } f ( ) ; f.call ( o ) ;
different behavior of keyword `` this '' between node.js and browsers
JS
I 'm using CSS resize : both ; property to let users resize my content . See the code below.Is there a way to resize this table step by step using CSS , for example , by [ 10,10 ] pixels ? JavaScript is also OK . I 've searched the web , but could not find anything . Here is the working fiddle for you to play with code...
.foo { resize : both ; min-width : 250px ; width : auto ; text-align : center ; min-height : 30px ; border : 1px solid # 515151 ; border-radius : 6px ; position : absolute ; padding : 0 ; overflow : hidden ; text-shadow : 1px 1px 1px rgba ( 0,0,0,0.33 ) ; box-shadow : 5px 5px rgba ( 0,0,0 , 0.1 ) ; } .thClass { margin-...
Resize by fixed value using CSS
JS
What is the benefit of prepending async here ?
async function asyncFunc ( ) { return new Promise ( function ( resolve , reject ) { } ) ; }
What is the benefit of prepending async to a function that returns a promise ?
JS
Got a tricky one where I want to add a class to all the parent < tr > 's of < td > 's which have either a < span > or a < div > element within them . So I have a table with markup as below : So I want the < td > 's that have either a < span > or < div > to have a class added to them by jQuery ... I ca n't seem to work ...
< table > < tr > < td > < /td > < td > < /td > < td > < div > < /div > < /td > < td > < /td > < /tr > < tr > < td > < span > < /span > < /td > < td > < /td > < td > < div > < /div > < /td > < td > < /td > < /tr > < /table >
jQuery find elements that match criteria
JS
I am trying to create an array for listing purposes in Ionic Framework and check all the callcenter name 's first char to add them in an alphabet array.Replacing value = 123 with value = ' # ' causes Google Chrome and Google Chrome Canary to malfunction and immediately use up to 100 % of RAM in Mac.Is this a Javascript...
for ( var i = 0 ; i < callcenterList.length ; i++ ) { var value = callcenterList [ i ] ._owner & & callcenterList [ i ] ._owner.company.name [ 0 ] ; if ( ( alphabet.indexOf ( value ) == -1 & & isNaN ( parseInt ( value ) ) ) || ( isNaN ( alphabet [ 0 ] ) & & ! isNaN ( value ) ) ) { if ( ! isNaN ( value ) ) value = 123 ;...
List manipulation leads to infinite loop
JS
I have a page that contains a random number of rows , each row has 2 cols.The challenge is to make this two columns of the same height for each row.I do that with JS.When on page are less then 30-40 rows it 's all good.But , when there is more then 200 rows , chrome start to lag for a couple of secs.I 've created a dem...
var len = document.getElementById ( `` translateContainer '' ) .children.length ; for ( var i = 0 ; i < len ; i++ ) { var height = document.getElementById ( `` origin_ '' +i ) .offsetHeight + 'px ' , col1 = document.getElementById ( `` column_ '' +i ) , col2 = document.getElementById ( `` column_sec_ '' +i ) ; console....
Why does Chrome render JavaScript so slowly ?
JS
I 'm studying how to use generator in JavaScript.Since generator returns iterator , I thought I could use it like iterable.filter ( ) like array.prototype.filter.But , iterable object does not have filter , map , forEach , reduce method.So , I made a generator version of filter , map , reduce , forEach method like the ...
'use strict ' ; function* range ( n ) { for ( let i = 1 ; i < = n ; i++ ) { yield i ; } } function* filter ( context , predicate ) { for ( let i of context ) { if ( predicate ( i ) === true ) { yield i ; } } } function isEven ( value ) { return value % 2 === 0 ; } console.log ( ... filter ( range ( 10 ) , isEven ) ) ; ...
Is there any way I can apply filter method to a custom iterator ?
JS
I am building up a multi-step questionnaire . I have 3 questions ( 3 divs ) , the DOM looks like this ( Pseudo-code ) . My question are 1.How can I read the value from the field which type is url ( type='url ' ) in q3 ? 2.What do read only the non-empty text/textarea/url fields ? Meaning I only want to read the text fi...
< div id=q1 > < input type='text ' id='q1text ' > < input type='button ' > // this btn will hide q1 and show q2 . < /div > < div id=q2 style= '' display : none '' > < input type='textarea ' id='q2textarea ' > < input type='button ' > // this btn will hide q2 and show q3 < /div > < div id=q3 style= '' display : none '' ...
jQuery to read non-empty and visible text fields
JS
I have made xiaomi clock for my practise but there are one problem , i cant make color spreading dial.I want to spread white color in dial one by one , and it going with triangle and behind dial opacity are decreases.Here is what I want to acheive IMG : - Video : - https : //vimeo.com/262815342Codepen
var clock = `` '' ; for ( var i = 0 ; i < 360 ; i++ ) { clock += `` < div id='dials ' > < div id='cutline ' > < /div > < /div > '' ; } //clock += `` < div id='circle ' > < /div > '' ; clock += `` < div id='dot ' > < /div > '' ; clock += `` < div id='mline ' > < /div > '' ; clock += `` < div id='hline ' > < /div > '' ; ...
How to Spread color in dials one by one
JS
What 's the proper way for loading jQuery functions in Angular 2 ? I 've added my jQuery to ngAfterViewInit . It works fine for one route , but if I navigate to another one ( e.g . from id : 1 to id : 2 ) , it does n't work for the second one ( I 'm using the same component for both ) .It works using ngAfterViewChecked...
$ ( '.chips ' ) .on ( 'chip.add ' , ( e , chip ) = > { console.log ( e , chip ) ; } ) ;
Loading jQuery functions in Angular 2
JS
just started to appreciate regex and I am practicing it on regexone.commy question is given the explanation about kleene `` * '' . I came up with an answer on my own '' but the solution is : is there any differences in terms of behavior with the two ? especially if I use it with javascript ? sorry for my bad english .
[ a-c ] * aa+b*c+ or a*b*c*
difference with Kleen regex expression
JS
Given a series of JSON co-ordinates typically in the format : I would like to draw a series of straight dotted paths which are connected with simple , fixed radius rounded corners . I have been looking at Slope Intercept Form to calculate the points along the straight line but I am a little perplexed as to the approach...
{ from : { x:0 , y:0 } , to : { x:0 , y:10 } , ... }
Interconnected curved lines
JS
In a blog project that I 'm playing with I have 'posts ' . Here 's the assemble block from my Gruntfile : Each post is represented in markdown , with a dash of YFM , like so : Now , in my default.hbs , I have the standard things . I did a quick { { inspect page } } to see what variables I have handy . I can see in ther...
assemble : { options : { layout : [ 'src/layouts/default.hbs ' ] , data : [ 'src/data/* . { json , yml } ' ] } , pages : { src : [ 'src/posts/**/*.md ' ] , dest : 'tmp/posts/ ' } } -- -date : '20131129'latitude : 7.113309999999999longitude : -73.120468city : Bucaramangacountry : Colombia -- - # A familiar face ... And ...
How to provide a link to the 'next post '
JS
Is there a standard defined how would JavaScript be compared , on Chrome console I get thisWhich is highly unintutive , and I ca n't even make sense what logic is being applied , and they look repeatable so does n't look based on object id ( ref ) etc , so is there any documentation for it ?
[ 10,0,0 ] > [ 1,0,0 ] true [ 10,0,0 ] > [ 5,0,0 ] false [ 5 , 0 , 0 , 0 ] < [ 10 , 0 , 0 , 0 ] //repeatablefalse [ 10,0,0,0 ] > [ 9,0,0,0 ] false [ 11,0,0,0 ] > [ 10,0,0,0 ] true
How are Javascript array compared ?
JS
I 'm having problems opening a new tab window after some amount of time . I did 2 different experiments . On the first experiment I used the setTimeout ( ... ) function and on the second experiment I used a custom sleep ( ... ) function.Experiment 1 : On this experiment both browsers : Chrome and Firefox behave in the ...
... $ ( '.button_test ' ) .click ( ( ) = > { setTimeout ( ( ) = > { let newForm = $ ( ' < form > ' ) .attr ( { method : 'GET ' , action : 'https : //www.google.com/search ' , } ) ; $ ( ' < input > ' ) .attr ( { type : 'hidden ' , name : ' q ' , value : 'Steve Jobs ' , } ) .appendTo ( newForm ) ; let new_win_content = `...
New tab window gets blocked when tried to open it after some amount of time
JS
I am building a component based app project with angular 1.5.5I am creating with d3js some .floating-node and for each i create a new $ scope and append inside a compiled component.This part of the code look like : This part of the code work perfectly.And this is mycomponentBut when I get in my mycomponent component . ...
nodeEnter.each ( ( ) = > { let childScope = this. $ scope. $ new ( ) ; childScope.test = `` test '' ; let compiled = this. $ compile ( ' < mycomponent > < /mycomponent > ' ) ( childScope ) ; ( this.mainContainer ) .append ( compiled ) ; } ) ; export default class Mycomponent { constructor ( $ scope ) { console.log ( $ ...
Angular get new scope through another component
JS
Here is a code to create an array of arrays named sims through a for loop and using str1 . so far I need to define the sims length manually , equal to length of str1 like : let sims = [ [ ] , [ ] , [ ] , [ ] ] ; ( four arrays equal to four words on str1 ) how can I fill sims with arrays programmatically ?
var str1 = `` do you ever looked '' ; var str2 = `` do you fr ever looked '' ; let sims = [ [ ] , [ ] , [ ] , [ ] ] ; // instead I want let sims = [ ] ; let s1 = str1.split ( `` `` ) let s2 = str2.split ( `` `` ) for ( var j = 0 ; j < s1.length ; j++ ) { for ( var i = 0 ; i < s2.length ; i++ ) { sims [ j ] .push ( s1 [...
fill an array with arrays programmatically
JS
I have a HTML fragment that I 'm objectifying via jQuery for the purpose of extracting some data from it . This fragment has some image resources that I do n't want the browser to download . Is there a way to do it.A simplified version of my current code :
var html = ' < p class= '' data '' > Blah Blah < /p > ... < img src= '' /a/b/ ... png '' > ... < div > ... < /div > ' ; var obj = $ ( html ) ; // this makes the browser download the contained images as well ! ! ! var myData = { item_1 : obj.find ( '.data : first ' ) .text ( ) , item_2 : obj.find ( '.data2 : first ' ) ....
Is there a way to prevent loading of images in a jQuery objectified HTML fragment
JS
I want to put `` < /script > '' in a variable in JavaScript but it will be consider as end tag like below example : Does anyone know a solution ?
< script > content.value = aval + ' < script > ma_gallery ( `` ' + varimgurl + ' '' ) ; < /script > '+ sevom ; < /script >
put `` < /script > '' in a variable in JavaScript
JS
I 'm approaching learning JavaScript from a Ruby background , so I 'm having some trouble understanding ( and putting this into words ) why my code is failing to produce the results I need . I ran this at pythontutor.com to see a step-by-step walkthrough of whats happening , and it confirms my suspicions . However , I ...
var DEFAULT_TEMP = 20 ; function Thermostat ( ) { this.temperature = DEFAULT_TEMP ; this.maxTemp = 25 ; this.powerMode = 'on ' ; this.displayColor = this.currentColor ( ) } ; Thermostat.prototype.downButton = function ( ) { if ( this.temperature === 10 ) { throw new Error ( 'temp can not be lower than 10dC ' ) ; } ; th...
Javascript function and prototype - basic routing issue through calling methods
JS
We use react and react-loadable.During our application initialization , we are verifying that the component.preload method is existing for each < Route / > we define.If the method is missing , we display a warning that show that the component should be loadable.We use webpack 4 , is there a way to automatically wrap th...
/** MyComponent.js : page component */export default ( ) = > < div > Hello world < /div > ; /** * preconfigured react-loadable * See https : //github.com/jamiebuilds/react-loadable # how-do-i-avoid-repetition ) */import MyLoadable from ' @ scopped/react-loadable ' ; /** loadable component */export default MyLoadable ( ...
In Webpack 4 , can we dynamically generate page chunk with import ( ) token so we can turn a react component into a react-loadable one ?
JS
While doing a code review of some Javascript files , my code review tool was showing `` � '' ( missing character symbol ) in one of the files . Upon further investigation , it turned out that the developer had used non-breaking spaces in their code . ( Probably a result of copy/pasting from web . ) To my surprise , thi...
//NOTE : All spaces in below code are non-breaking space ( 0xA0 ) , not space ( 0x20 ) function test ( ) { var mystr = 'hello ' ; alert ( mystr ) ; } test ( ) ;
Is non-breaking space always treated like whitespace in Javascript source ?
JS
I bind some type for my site : In most browsers this types recognize perfectly but IE do n't see this type because of ttf extensions . But the problem is that IE10+ are n't support this condition. < ! -- [ if IE ] > ... < ! [ endif ] -- > Is there any way to make specific css code for IE10 to change type to usuall , fo...
@ font-face { font-family : WILLS ; src : url ( WILLS.TTF ) ; }
make specific css code for IE10
JS
In my React app I have a component that send request to an online service that is capable to handle 50 requests max . I got a new request now to execute 7000 MAC ’ s.I would like to extend the fetchData function so basically it will send only 50 IP ’ s and will wait till iteration is complete.When the iteration is comp...
function App ( ) { const [ data , setData ] = useState ( [ ] ) ; useEffect ( ( ) = > { const fetchData = async ( ) = > { await axios.all ( [ axios.get ( `` /ipdn/ < MAC ADDRESS > '' , { timeout : 10000 } ) , axios.get ( `` /ipdn/ < MAC ADDRESS > '' , { timeout : 10000 } ) // Adding all the mac address ... ... . ] ) .th...
How to use Promise.all to handle thousands of request
JS
The example below works fine , however , I am trying to make a function handleArcs ( ) more universal ( i.e . handleLayer ( ) ) . My layerVar has a property onEachFeature , which applies a method onEachArc to each feature of the layer . I want handleArcs ( ) to take a function onEachArc ( ) as an argument , but it does...
function onEachArc ( feature , layer ) { if ( feature.properties ) { layer.bindPopup ( `` < b > '' + feature.properties.linkstr + `` < /b > has speed `` + feature.properties.speed + `` . `` ) ; } } ; function handleArcs ( data , layerVar , layerName , thisShouldBeAFunction ) { alert ( typeof thisShouldBeAFunction ) ; /...
JavaScript typeof function passed as an argument returns undefined
JS
Relevant fiddle : https : //jsfiddle.net/tqf4zea7/1/I 'm using $ q in an angular controller . To test some scenarios , I created an array on the scope to push messages to : I have set up a function that returns a $ q function as so : I then have a .then ( ) call on the result that looks like this : Since I only want to...
$ scope.messages = [ ] ; function returnAPromise ( valToReturn ) { return $ q ( function ( resolve , reject ) { $ timeout ( function ( ) { resolve ( valToReturn ) ; } , 500 ) ; } ) ; } returnAPromise ( 'third ' ) .then ( $ scope.messages.push ) ; VM289 angular.js:12520 TypeError : Array.prototype.push called on null or...
Why is $ scope.someArray.push not a valid function to pass to .then on $ q.promise
JS
I 'm using vscode to write some typescript , and I have set a breakpoint . When I open the Debug pane and ask it to evaluate an object , what is it doing to produce the string representation ? The reason I am asking is because I am using this solution to control the way that console.log renders an instance of a class ,...
cls { property : 'property ' , hello : 'override ' , newProperty : 'new property ' } Greeter3Generated { property : 'property ' , hello : 'override ' , newProperty : 'new property ' } function classDecorator3 < T extends { new ( ... args : any [ ] ) : { } } > ( constructor : T ) { const cls = class extends constructor ...
vscode debugger with typescript : what determines how an object is rendered ?
JS
I have been going through some online tutorials on Node.js . What I understood is that , on using require ( ./file-path ) function , the node gets the content of that file and wraps inside an immediately invoking functionI understood the difference between exports and module.exports . That 's all I can see in the inter...
( function ( exports , require , module , __filename , __dirname ) { // content } ( ) )
Why we need to pass module.exports as a parameter since we are already passing module as a parameter ?
JS
I 've searched through the answers here , but I can only find this question answered for other languages . So I have 2 Uint8 typed arrays . I want to replace the contents of arr2 with arr1 starting at the 4th position . So that arr2 will be : If I was n't trying to do this in the middle of the array I could use set lik...
var arr1 = [ 0,0,0 ] ; var arr2 = [ 0,1,2,3,4,5,6,7,8,9 ] ; arr2 = [ 0,1,2,0,0,0,6,7,8,9 ] ; arr2.set ( arr1 ) ; arr2 = [ 0,0,0,4,5,6,7,8,9 ] ;
Copy an array into the middle of a larger array in Javascript
JS
I 'm trying to understand how the stream is transmitted through the pipe in RXjs . I know that this should not be a concern because that 's the whole idea with async streams - but still there 's something I want to understand.Looking at this code : Result : I believe ( IIUC ) that the diagram is something like this : (...
var source = Rx.Observable .range ( 1 , 3 ) .flatMapLatest ( function ( x ) { // ` switch ` these days ... return Rx.Observable.range ( x*100 , 2 ) ; } ) ; source.subscribe ( value = > console.log ( ' I got a value ' , value ) ) I got a value 100I got a value 200I got a value 300I got a value 301 -- -- 1 -- -- -- -- -2...
How are asynchronous streams transmitted in RXJS ?
JS
I 've managed to embed Google Calendar into a React component , but the problem is I could observe that the embedded calendar does n't get the latest events that is added to the email that is authenticated with gapi.The calendar iframe URL is this https : //calendar.google.com/calendar/b/1/embed ? src= { VALID_CALENDAR...
const CALENDAR_EMBED_BASE_URL = 'https : //calendar.google.com/calendar/embed ? src= ' ; export const getCalendarEmbedUrl = email = > ` $ { CALENDAR_EMBED_BASE_URL } $ { email } ` ; import React , { PureComponent } from 'react ' ; import { getCalendarEmbedUrl } from 'calendar.util.js ' ; class CalendarIframe extends Pu...
Calendar iframe does n't show all latest created events ( especially shared calendar events )
JS
How do you go about writing out HTML to the calling position of a jQuery function ? I have an HTML page that contains the following jQuery/JS code : How do I get functionName to append/write out new content where it is called , rather than selecting another ID in the document and appending after . JavaScript 's documen...
... HTML contents ... < script > functionName ( ) ; < /script > ... More HTML Contents ...
Writing new HTML out to the calling position
JS
What is the meaning of the above statement ? I mean , this looks like it will always execute so why bother with the if statement ? updated : one reason might be remnants of scripting on the server side . Any other ideas ? updated2 : could as easily change the value of the assignment without bothering with the if statem...
if ( 1 ) { google_conversion_value = 1 ; }
Strange Javascript statement
JS
In this piece of code , flow is not complaining about the value dog being set on the state . It seems to be ignoring the NamespaceData definition . I 've set up the types so it should complain . I 'm running on nuclide and flow is working properly for everything else.All of the properties of action such as namespace , ...
// @ flowimport { NAMESPACE_SET } from '../actions/NamespaceActions'type NamespaceData = { project : string , collection : string , } type NamespaceState = { [ namespace : string ] : NamespaceData , } const initialState : NamespaceState = { } function namespaceReducer ( state : NamespaceState = initialState , action : ...
Flow does n't complain about incorrect type
JS
I 'm building a site for a client and I 'm using a pre-build theme as a starting place . It came with a js file that has an on click function for the mobile nav , everything was working fine , but when I added a script tag for jQuery the mobile nav broke and the console is giving this error : Uncaught TypeError : Can n...
< div id= '' navigation '' > < span id= '' mobile-navigation '' > & nbsp ; < /span > < h1 class= '' nav-h1 '' > < a href= '' index.html '' class= '' logo '' > < ! -- < img src= '' images/logo.png '' alt= '' '' > -- > Header < /a > < /h1 > < ul id= '' menu '' > < li class= '' selected navList '' > < a ui-sref= '' home '...
jQuery is interfering with javascript
JS
If I have this ES6 function declaration and invocation : ... the console.log ( ) statement shows only one argument with a value of `` 1 '' . `` bob '' is nowhere to be seen . Is this expected and/or desired behavior ? I would expect that default values would be available in the arguments object . If not , is there a wa...
function myFunction ( arg1 , arg2 = `` bob '' ) { console.log ( `` arguments '' , arguments ) ; } myFunction ( 1 ) ;
ES6 default values not available in function.arguments ?
JS
The official documentation as well as tons of articles on the internet say that 'some string ' is a primitive value , meaning that it creates a copy each time we assign it to a variable.However , this question ( and answer to it ) How to force JavaScript to deep copy a string ? demonstrates that actually V8 does not co...
let copy = someStringInitializedAbove
Why is the string literal considered a primitive type in JavaScript ?
JS
I 've added a change event listener input [ type='checkbox ' ] element , but even though I 've included the e.stopPropagation ( ) in my JS code , the event seems to bubble up to the click listener on the < li > element.My HTML structure : It 's important to note that that checkbox element does n't take up any space . R...
< li > < label class= '' checkboxContainer '' > < input type= '' checkbox '' > < span class= '' checkmark '' > < /span > < /label > Lorem ipsum < /li > const checkbox = document.querySelector ( `` .checkboxContainer input '' ) ; checkbox.addEventListener ( `` change '' , e = > { e.stopPropagation ( ) ; //rest of code g...
Checkbox change event bubbles up to parent li element while using e.stopPropagation ( )
JS
HTML5 speech is not working on Safari on a mac 10.0.1 , I get the error , TypeError : Argument 1 ( 'utterance ' ) to SpeechSynthesis.speak must be an instance of SpeechSynthesisUtteranceIt works on Chrome and Firefox , and I 'm pretty sure it used to work on Safari ...
var u = new SpeechSynthesisUtterance ( ) ; u.text = `` hello world '' ; u.lang = `` en '' ; window.speechSynthesis.speak ( u ) ;
HTML speech not working on Safari mac `` TypeError ''
JS
I am trying to learn react hooks . I need help in understanding does react functions always reset hook state every time it renders.Here is a small example of scroll where I am trying to fix the headerOutput : It works fine.Now with react hooks same logic . I am just trying to look for the behavior of FixedHeader state....
class Header extends Component { constructor ( props ) { super ( props ) ; console.log ( `` Constructor '' ) this.state = { fixed : false } ; } handleScroll = ( ) = > { console.log ( window.scrollY ) ; console.log ( this.state.fixed ) ; if ( window.scrollY > = 25 & & ! this.state.fixed ) { this.setState ( { fixed : tru...
Performance comparison between react hooks and react class
JS
I am trying to parse a HTML code in order to extract all links in it . To avoid unavailable links I remove the commented code that begins with < ! -- and ends with -- > .Here comes the problem : In the HTML code I may find some JavaScript code , for example : and the weird thing is that the js code is commented but it ...
< html > < HEAD > < SCRIPT LANGUAGE= '' JavaScript '' > < ! -- Beginif ( document.images ) { var pic2 = new Image ( ) ; // for the inactive image pic2.src = `` pic2.jpg '' ; var title2 = new Image ( ) ; title2.src = `` title2.jpg '' ; } ... -- >
HTML with commented JavaScript code
JS
I have the above code snippet which creates a table . I want to extract the MARkS from the table and store it in an array.gives output as UNDEFINEDSo how can I do so ? NOTE : I can not edit the html of the page .
< table border= '' 1 '' cellpadding= '' 2 '' cellspacing= '' 0 '' width= '' 75 % '' bordercolor= '' # 000000 '' > < tbody > < tr bgcolor= '' mediumblue '' > < td width= '' 20 % '' > < p align= '' center '' > < font face= '' Arial '' color= '' white '' size= '' 2 '' > < strong > SUB CODE < /strong > < /font > < /p > < /...
How to get data from columns of a table in HTML
JS
I 'm working on a javascript game that simulates gravitational forces . It uses the HTML5 canvas element to draw 2D ellipses for planets . I test my game in Google Chrome . Here 's a link to the game : http : //gravitygame.hostingsiteforfree.com/index.php ? page=playHTMLUp until May 24th , it worked just fine . However...
var i = bodies.length ; while ( i -- ) { var I = bodies [ i ] ; var planetRad = ( I.width/2 ) *_scale ; if ( _showTrails ) { //draw the planet 's trail } if ( //the planet is completely off the screen ) { //draw a red planet on the edge of the screen ctx.beginPath ( ) ; ctx.arc ( nX , nY , 2.5 , 0 , TWOPI ) ; ctx.fillS...
Why would the canvas2d context no longer fill ellipses ?
JS
I 'm trying to squeeze every last bit of performance out of my canvas game ; recently I found out that clearing the canvas is very performance heavy , so I 'm trying to find a way to replace clearing the entire canvas every frame . However I 'm finding a few problems with the new method I 'm trying , which is to clear ...
var enemyCtx = document.getElementById ( 'enemy ' ) .getContext ( '2d ' ) ; var game = { w : 800 , h : 500 } ; var enemies = [ ] ; window.addEventListener ( 'load ' , function ( ) { for ( var i = 0 ; i < 200 ; i++ ) { enemies [ enemies.length ] = new Enemy ( ) ; } update ( ) ; } , false ) ; var buffer = document.create...
Graphics on canvas not being cleared properly ?
JS
This is the for each loop to render the data I want to hide if data attribute value is data= '' people '' and display it in another div.How can I achieve this ? Thanks in advance !
< ul data-bind= '' foreach : { data : PersonData , as : 'ref ' } '' > < li > < a data-bind= '' attr : { data : ref.Filter } '' class= '' filterbtn '' > < span data-bind= '' html : ref.Name '' > < /span > < span data-bind= '' text : ref.Age '' class= '' age '' > < /span > < /a > < /li > < /ul >
Depending on data attribute how to Hide the tag and display in another div
JS
I 'm not having a problem , not trying to fix anything . I 'm just curious why Javascript works this way . I 've poked around with google , but `` js function no name '' gets a lot of hits about how to define and use anonymous functions ( not what I 'm looking for ) . And there 's hardly anything out there about declar...
var objectOne = { apple : function ( ) { } } var objectTwo = { } objectTwo.banana = function ( ) { } var objectThree = { catapult : null } objectThree.catapult = function ( ) { } function one ( ) { } var two = function ( ) { }
Javascript : functions in an object get automatically named ( or not ) depending on declaration syntax -- why ?
JS
I have multiple canvas in one screen using fabricJS.I have added some ITexts , Text Box , Image , Background in each canvas.I have some scalling options , like 25 % , 50 % , 100 % to 300 % in increasing order of 25 % .If my current default scale is 100 % it means scalefactor is 1 , now if I apply 125 or 150 or whatever...
const scalefactor = Number ( this.selectedScale ) / 100 ; this.canvas.forEach ( ( canvas : any , index ) = > { this.canvas [ index ] .setDimensions ( { width : Number ( this.canvas [ index ] .originalCanvasWidth * scalefactor ) , height : Number ( this.canvas [ index ] .originalCanvasHeight * scalefactor ) } ) ; this.c...
how to apply back and forth scalling to all objects in fabricJS ?
JS
How does this : differ from this : How do the patterns differ ? When would I use one over the other ?
var obj = obj || { } ; obj.Something = ( function ( ) { function Something ( ) { } ; Something.prototype.someMethod = function ( ) { } ; return Something ; } ) ( ) ; obj.Something = function ( ) { } ; obj.Something.prototype = { } ;
How do these patterns differ ?
JS
I saw the following JavaScript functions works exactly same , Then what is the difference between them other than syntax.The function are : I call them in the same way as : Please dont ' tell me there syntax is different , Other than that is there any difference like Thanks in advance !
var functionName=function ( ) { //some code here } ; function functionName ( ) { //some code here } functionName ( ) ; 1 ) speed of execution2 ) Memory utilization etc .
What is the difference between these two ?
JS
Since iojs merged into Node . I assumed I can run koajs without the -- harmony tag ( because it 'll have generators from es6 supported ) .So within my server.js file I have : My package.json file has `` koa '' : `` ^1.1.2 '' .I run node server.js and get : Any ideas why it 's complaining ? Do I still need to use the --...
var koa = require ( 'koa ' ) ; var app = koa ( ) ; app.use ( function * ( ) { this.body = 'Hello World ' ; } ) ; app.listen ( 3000 ) ; app.use ( function * ( ) { ^SyntaxError : Unexpected token *
Can I run Koajs without the -- harmony tag
JS
This is just trivia / curiosity as I stumble across this situation a number of times.Is it possible to shorten/destructure the following types of assignments ? Naively , I tried newValue = { value } but it does n't work , as that syntax is normally used to destructure variables from objects with the same key name .
newValue = value.value
How to destructure newValue = value.value ?
JS
Tested in Firefox :
a = [ ] + 0 ; b = 0 ; alert ( a ) ; // 0alert ( b ) ; // 0alert ( ! a ) ; // falsealert ( ! b ) ; // true
Can someone explain this behavior in javascript ?
JS
I have a circle which is created with the following styling : I would like to have an outline around this circle , however , I would like it to only be around part of the circle to produce a percentage.For example:50 % will create an outline starting from 12 o'clock to 6 o'clock25 % will create an outline starting from...
.circle { width : 150px ; height : 150px ; border-radius : 100 % ; -webkit-border-radius : 100 % ; }
Outlining a circular element with CSS
JS
When I run this code : I get the following output : foo , undefined , trueWhat I do not understand is how the object returned by the constructor function foo somehow manages to allocate a new memory location for b. I was totally expecting the last output to be true because I only get 1 foo output.That this works is gre...
function foo ( ) { console.log ( `` foo '' ) ; var self = this ; this.a = function ( ) { return arguments.length == 0 ? self.b : ( self.b = arguments [ 0 ] ) ; } ; } ; function bar ( ) { } ; bar.prototype = new foo ( ) ; var a = new bar ( ) ; var b = new bar ( ) ; console.log ( a.a ( ) ) ; b.a ( true ) ; console.log ( ...
JavaScript inheritance magic
JS
I 've just been looking at the _.isEqual function of Underscore.js and a section of the code goes something like this : I 'm just wondering if there 's any case where the third statement could be reached and evaluate to true ? Edit : Just to be clear , this is n't my own code I 'm talking about , I 'm reading the sourc...
if ( a === b ) return true ; if ( typeof a ! == typeof b ) return false ; if ( a == b ) return true ;
Is this line from Underscore.js doing equality checking actually necessary ?
JS
i want to break out each three items in a list and add a class to that child like ; any idea ?
< ul > < li > 1 < /li > < li > 2 < /li > < li > 3 < /li > < ! -- target list item -- > < li > 4 < /li > < li > 5 < /li > < li > 6 < /li > < ! -- target list item -- > < li > 7 < /li > < /ul >
How to break out of .each ( ) by index number
JS
I 'm not getting any result in my divHere is my jqueryMy JSONand I have a div called recipes in my htmli couldnt get any of the resultsI want my result to be seen on html file when my btnsearch button is pressed but it is not showing a thing
$ ( ' # btnsearchres ' ) .click ( function ( ) { var $ server ; var content ; $ server = 'http : //localhost/XDK/ ' ; $ .getJSON ( `` http : //localhost/XDK/timeline.php '' , function ( data ) { $ .each ( data.recipes , function ( i , post ) { content = ' < p > ' + post.i_name + ' < /p > ' ; content += ' < p > ' + post...
I 'm unable to find a result in my div
JS
We want to format a number so that the resulting string has length of X ( in our case it 's a length of 3 ) .We 're OK with exponent notation if the number is too low or too big , however we prefer to display a number without it.That 's exactly what g notation is for https : //github.com/d3/d3-formatHowever , d3 someho...
d3.format ( `` .2g '' ) ( 0.0000020852945934254138 ) > > `` 0.0000021 '' d3.format ( `` .2g '' ) ( 0.00000020852945934254138 ) > > `` 2.1e-7 ''
Change which notation d3.format uses for the ' g ' type
JS
I have the following regex pattern and string : I would like to just extract the main expression is ( without the modifiers ) from var patt1 using another regular expression , which we can call var patt2 for arguments sake.How is this possible to do in vanilla JavaScript ?
var str= '' Is this all there is ? `` ; var patt1=/is/gi ;
How do I do run a regex on a regex in javascript ?
JS
I am trying to order an array of objects , in this context houses , and I am trying to write a function where users can order the array of houses by the distance of a landmark . Say I have the following data returned from an API that I am calling through AJAX : I already have some code that will return the houses that ...
`` data '' : [ { 'id ' : 123 , 'address ' : '12 street name ' , 'city ' : 'City Name ' , 'landmarks ' : [ { 'name ' : 'landmark one ' , 'distanceInMiles ' : 0.6 } , { 'name ' : 'landmark two ' , 'distanceInMiles ' : 0.4 } ] } , { 'id ' : 345 , 'address ' : '22 street name ' , 'city ' : 'City Name ' , 'landmarks ' : [ {...
How to sort an array by the value of an object within a nested array
JS
Is there a way to determine whether a browser supports using data URIs for hyperlinks , besides browser sniffing ? Here 's the context : I 'm creating a link that either downloads a CSV file of information generated via JavaScript using a handy data URI or , if the browser does not support the use of data URIs for hype...
if ( window.URL ) { downloadLink.href = `` data : text/csv ; charset=utf-8 , '' + encodeURIComponent ( data ) ; downloadLink.setAttribute ( `` download '' , '' download.csv '' ) ; } else { downloadLink.href= `` # '' ; downloadLink.innerHTML = `` table view '' ; downloadLink.onclick = function ( ) { // build and display...
How to determine if the browser supports data URIs for hyperlinks
JS
Maybe is another stupid question but it 's driving me crazy.Basically I 've got this form to input 20 images ( generated by a for ) I need to show a Thumbinail before the uploading , at the moment it works just for one of the fields ( # inputGroupFile3 and # thumb-output3 ) .Basically what I need to have is something l...
< ? php for ( $ i=0 ; $ i < 20 ; $ i++ ) { echo ' < div class= '' col-xl-4 col-lg-4 col-md-6 '' > ' ; echo ' < div class= '' file-field '' > ' ; echo ' < div class= '' z-depth-1-half mb-4 '' id= '' thumb-output'. $ i . ' '' > < /div > ' ; echo ' < div class= '' d-flex justify-content-center '' > ' ; echo ' < div class=...
Use Data API to access position value of image being loaded
JS
The following code ... Assume that the yield is inside a generator function and that something and else are defined , etc ... .produces the following in V8 ( Chrome or Nodejs ) : ... and this in Firefox : I first noticed this in a bluebird coroutine I was writing . The fix is to wrap the yield wait ( ) in a parentheses...
const value = something || yield else ( ) ; const start = initial || yield wait ( ) ; ^^^^^SyntaxError : Unexpected strict mode reserved word SyntaxError : yield is a reserved identifier [ rv ] = yield [ expression ] ;
What is the exact syntactic ambiguity that requires parentheses around a yield expression in an OR assignment ?
JS
Now , I am working on project where users can create their own time lines . Each timeline has events . There 's a problem with event title.User can create event with very long title . For example : or Title displays with h3 and word-break : break-allExamples : I suppose that for the first example it works well enough ....
` 12312312312312312312312313211233123213133gsfsfsfsdfserwerwerwerwesdfsdf ` День победы русской эскадры под командованием Ф.Ф . Ушакова над турецкой эскадрой у мыса Тендра
Proper wordbreaking with CSS and JS
JS
Hello people please help ! I have gone through all the jquery issues in stackoverflow . I tried some of the solutions but i am not getting the result as i want . I am making a one page website for my company but i am having trouble in bringing responsiveness to it.The code is as follows : There are few things which i h...
< ! DOCTYPE html > < html xmlns= '' http : //www.w3.org/1999/xhtml '' > < head > < title > Top Accountant . Providing solution for all your accounting needs < /title > < meta name= '' viewport '' content= '' width=device-width , initial-scale=1 '' / > < link type= '' text/css '' rel= '' stylesheet '' href= '' css/boots...
jquery and bootstrap.js not working
JS
In my JavaScript code , and in Chrome dev tools I write : And get this error : And a is not set to `` foo '' . I know this is a valid pattern in JavaScript . What am I missing ?
a = b || `` foo '' ; ReferenceError : b is not defined
A = b || `` foo '' ; complains that ' b ' is undefined and does not assign a to `` foo '' . What am I missing ?
JS
I 'm adding JavaScript to a SharePoint and I 'm trying to write a function that gets an Excel document , or rather the data in it , from a library . I 've already figured out how to do that , but the files in question are too large to be returned . I 've considered manually setting the size limit for ajax , but I have ...
$ ( `` # button '' ) .click ( function ( ) { readFileRow ( libraryUrl , `` FileName.xlsx '' , `` Sheet1 '' , 1 , `` E '' , [ ] ) .done ( function ( cells ) { console.log ( xmlToJson ( cells.documentElement ) ) ; } ) ; } ) ; /** * Reads a file in SharePoint Library via ExcelRest and returns the document * * @ params str...
Trying to get an Excel document through ajax , running into async issues
JS
I want to get a PHP variable from Javascript . so I use help from HTMLAnd then I give the value from JavascriptAnd finally take it in PHPIs this dangerous and have any bug possibilities ? Thank you
< input type= '' text '' value= '' '' name= '' number1 '' id= '' number '' style= '' display : none ; '' > var c = ( Math.floor ( ( Math.random ( ) * 8 ) + 5 ) ) .toString ( ) ; document.getElementById ( `` number '' ) .value = c ; $ number = $ _POST [ `` number1 '' ] ;
HTML to Javascript to PHP . Is this dangerous ?
JS
I 'm using the framework GameClosure but I meet ​​an error when I tried to create a filter.I went to look at the DocsOn the DevKit Docs I found this : GameClosure DevKit Docs - Class : ui.filter.FilterThis is the error :
import ui.filter.Filter as Filter ; var filter = new Filter ( ) ; Error loading module : [ [ import ui.filter.Filter as Filter ] ] requested by : ./src/Level0/Level0.js current directory : http : //127.0.0.1:8802/simulate/ricettivointermedio/native-ios/ Error : requested import ( ui.filter.Filter ) not found looked in ...
GameClosure - Error with Filter
JS
Possible Duplicate : What is the explanation for these bizarre JavaScript behaviours mentioned in the 'Wat ' talk for CodeMash 2012 ? Could someone explain to me how thees returning results can be different in javascript :
› { } + [ ] » 0› [ ] + { } » `` [ object Object ] ''
How can { } + [ ] and [ ] + { } results be different
JS
The following prints ' A ' as expected , since the data type is different so the array is coaxed into a primitive form which is false for empty arrays.But then why the following code too prints ' A ' ?
if ( [ ] == false ) console.log ( ' A ' ) ; else console.log ( ' B ' ) ; if ( [ ] ) console.log ( ' A ' ) ; else console.log ( ' B ' ) ;
Why is ` [ ] == false ` is true but just ` [ ] ` evaluates to true ?
JS
Given an ES6 class : and a variety of functions such asIs there an efficient way to determine if a function is a method of C i.e.I know one could recursively loop through the prototype chain , but that would be an expensive operation.Linking related questions : JavaScript ES6 : Test for arrow function , built-in functi...
class C { x ( ) { } fnIsMethodOfC ( fn ) { return /* ? */ } } function y ( ) { } z = ( ) = > { } c = new C ( ) c.fnIsMethodOfC ( c.x ) === truec.fnIsMethodOfC ( C.prototype.x ) === truec.fnIsMethodOfC ( y ) === falsec.fnIsMethodOfC ( z ) === false
ES6 detect if a function is on prototype chain of a class instance
JS
Is there a babel plugin to avoid long import path in CRA ? I 've searching a lot on the web but I ca n't find the best way to achieve this.Actual : Expected
import MyComponent from '../../../../components/MyComponent ' import MyComponent from 'components/MyComponent '
How to avoid very long paths and use absolute paths within a Create React App project ?
JS
I accidentally wrote a wrong JavaScript syntax ( I think so ) . code is jsfiddleis syntax is correct ? Thanks .
var temp = { } ; temp.a = 34 ; height:34 , //should fail here . temp.b = 56 ;
Why browser is not throwing exception for syntax error ?
JS
I 'm trying to use Jquery to firstly identify specific words within a span tag , and then colour the background of a div it is nested in . The HTML looks like this : So I think I need to use Jquery to identify if equals `` Workshop '' then color the div with class highlight ( for e.g . set background to # 000 ) . I nee...
< div class= '' highlight item1 ll3 '' > < div class= '' Image '' > < h2 class= '' Name '' > < div class= '' type '' > < span > Workshop < /span > < /div > < div class= '' Dates '' > < p class= '' Desc '' > Toddlers are especially welcome to BALTIC on Tuesdays . Join in the fun , as a BALTIC artist leads a practical se...
How to use Jquery to colour the background of an element , based on keywords within the html