text
stringlengths
46
37.3k
title
stringlengths
12
162
JS : Possible Duplicate : Use of .apply ( ) with 'new ' operator . Is this possible ? I have 5 or 6 variable assignments of the formAs you can see , a significant amount of portion of these constructors are very much alike . It would be nice if I could create a little generic currying builder that would allow me to do ...
Use apply with a function constructor
JS : Assume such situation : In C and C++ this is undefined behaviour , as described here : Undefined behavior and sequence pointsHowever , how does this situation look in : JavaScript , Java , PHP ... C # well , any other language which has compound operators ? I 'm bugfixing a Javascript - > C++ port right now in whi...
How do languages handle side effects of compound operators ?
JS : I am using `` nashorn '' javascript engine in java8 to evaluate some expressions during runtime . I have a util class for this with method : for which I created some unit tests . One of them goes like this : It worked fine for me while I was using java version `` 1.8.0_91 '' . But someone who used java version `` ...
JDK 1.8.0_92 Nashorn JS engine indexOf behaviour
JS : Im facing an issue after upgrading to Symfony 4.1 and switching to Encore.I tried to search for a source of problem and only after removing everything with jquery include from compose.js ( and includes ) the Error disappeared . But of course I need jquery ... As soon as I 'import jQuery from 'jquery '' or 'Encore....
Webpack Encore Jquery Maximum call stack size
JS : I am using a closure to create an object with private and public methods . It looks like this -But now I would like to have an object that has only private functions and that is inherited by another object . But is this possible in JavaScript ? <code> var Dog = ( function ( ) { function Dog ( ) { } var size = 'big...
Can you inherit private functions in JavaScript ?
JS : So I 'm writing this node.js application and I 'm trying to make it super fast and with a low memory footprint . I 've got a lot of string concatenation going on , functions like : If I do this like 100 million times right on the inner loop of my application , does the Javascript engine allocate and have to free t...
Should I statically allocate Javascript strings for memory performance ?
JS : I have a form in HTML which contains multiple same name fields . For example : Now on the server side ( C # ) , I have an action method and a model class Product : Now my question is : I am submitting the form using jquery $ .ajax method . On the server side the action method accepts a Product class array . Now ho...
How to serialize the form fields and send it to server , jquery ?
JS : I have this code that I 've stumbled upon . All the time I 've been working with arrow functions I 've seen on a { } format , what does this ( ) wrapper mean ? <code> const actionsMap = { [ GET_USER ] : ( state , action ) = > ( { post : action.msg } ) } ;
What does the arrow function with a ( ) after means ?
JS : I am working on [ this ] [ 1 ] d3 project . Basically I am trying to create a SQL like query builder . I can drop boxes to the drawing area & other operators inside the box . Then I should be able to connect them all . I am trying to translate 2 images which are nested in groups . I want to move the small items in...
d3js transforming nested group images
JS : For this question , I 'm not expecting a solution to solve something but would like to understand things better .. Some quote from the specifications : Edition 5.1 ( Link ) §15.2.3.5 Object.create ( O [ , Properties ] ) The create function creates a new object with a specified prototype . When the create function ...
x is not a function ... what would you expect Object.create to do with a constructor
JS : I have following 2 directives . In DirectiveA I am getting some data from remote server and then rendering a template with that data as anchor tag . Now when user click on any of the link , I broadcast event and listen to that event in DirectiveB . In DirectiveB I want to make another ajax request and when I recei...
execute/render a directive from another directive
JS : How can I make the left column in a table disappear using plain JS ? This is my approach : It works , but I have to use `` ugly '' loops.Maybe there is a more efficient way by just saying column [ 0 ] .display = `` none '' .Here is the fiddle . <code> < table id= '' tab '' border= '' 1 '' > < tr > < td > abc < /td...
Make entire column disappear
JS : Using C # for ASP.NET and MOSS development , we often have to embed JavaScript into our C # code . To accomplish this , there seems to be two prevalent schools of thought : The other school of thought is something like this : Is there a better way than either of these two methods ? I like the second personally , a...
How do you embed other programming languages into your code ?
JS : I use the following code to show tree items , https : //github.com/microsoft/vscode-extension-samples/tree/master/tree-view-sampleThe items which is shown in the tree is related to a file , if the file changed the number of the tree items should be changed accordingly ( using createFileSystemWatcher which works ok...
vsCode refresh tree when adding new Item
JS : What I 'm trying to do : I want to use Node to fire up two child processes in a particular order at a particular time , console logging their stdout as they stream , occasionally switching between the two . The output I want : Of course it 's super easy to do . Imperatively . But it 's also really ugly & stateful ...
Why does this console log twice ?
JS : I updated jquery so i could play with the new jquery mobile ui 1.3 and for some reason my form no longer update page any more , it worked previously but it was n't through ajax , it simply submitted the form without ajax , I would however like ajax to just fetch the new data and append it to the div instead of rel...
Ajax Form Submit not loading newly submitted data
JS : Possible Duplicate : How to encode a URL in JavaScript ? I am trying to send a url using the following code to a php code , but as the url include & a=12 & b=4 once I get the value of the `` a '' variable in my php code the last part of address is removed.url = http : //www.example.com/help.jpg ? x=10 & a=12 & b=4...
how to send a url using Javascript ajax ?
JS : Here is my code below : I am using ajaxFileUpload and here is my code to upload the same : This fileElementId is referring to image . Where image is picked only once . Tried assigning image to images [ ] as we do it from plain HTML . But still no luck as ajaxFileUpload.js throwing error as id not found with images...
How to upload multiple files from jqgrid and Laravel ?
JS : I 'm trying to use a visualization as a selector on a D3 costum chart . I 'm following the SDK documentation Here , and I ca n't make my example work.Basicly I star by declaring `` me '' var and enable the `` use as filter '' option.Then , when appending de svg element , I add the clear and end selecion methods : ...
Microstrategy Using a visualization as a selector D3 costum chart
JS : I 'm looping through files in a directory and storing the file details to an array data . The following code populates the array if I do n't attempt to run fs.stat to get things like the file create/edit date : If I move the data.push ( ... ) outside the fs.stat the array returns with the file data . Inside the fs...
Store fs.stat while looping through files into an array , in Node JS
JS : JSlint does n't like the use of Array constructors and there are no JSLint options for allowing them . Therefore , to create an Array of length n , the following is not allowed : Is the below the only way I can get around this ? In normal circumstances this is not a big deal ( using two lines of code instead of on...
Creating an n-sized Array while making JSLint happy ?
JS : I have this code : Why does foo.bar ( ) alert 2 while [ foo.bar ] [ 0 ] ( ) alerts undefined ? <code> var foo = { x : 2 , bar : function ( ) { alert ( this.x ) ; } } ;
Call a function from javascript array
JS : I want to upgrade to the lasted stable angular branch 1.4.7 . I am coming from 1.2.13.there is a angular-leaflet-directive in my project that was customized for the application . I am trying to figure out how to change the syntax in a function so it does not throw a error . console messagesfunctionerror is at 'mar...
how to correct syntax after angular update
JS : In one of the tests , I need to scroll into view of an element which can be done via scrollIntoView ( ) method parameterizing the script with an element located via Protractor : But , we can also find the element directly via getElementById ( ) : What is the difference between the two approaches ? The scrollIntoVi...
Locating elements in Protractor vs directly in JavaScript
JS : EDIT**In my word game there is a grid with 3 letter words . The aim of the game is to spell the words by clicking on the corresponding letters on the side . When an area in the grid is highlighted it indicates to the user the word to spell . The user clicks the letters on the side of the grid and they move to the ...
Accepting the animation
JS : Here is the code . You can test in Chrome ( F12 ) : This return an invisible character , this should be `` µ '' . It works fine in IE . But why ? In Chrome , returns `` '' ( not empty string , an invisible character ) In IE , returns `` µ '' In Firefox , return `` M '' ( not letter M ) <code> `` µ '' .toUpperCase ...
Javascript toUpperCase mess up in chrome for latin character
JS : Assume , for the sake of this question , that I want to be able to create a function in Javascript that appends all of the elements of one array to another array . One way to achieve this , if you have access to the destination array , is to say : Now , since Array.prototype.push.apply is pretty ugly , I want to a...
Why is apply not already bound to functions in Javascript ?
JS : I have to create a function to sort a string of numbers based on the 'weight ' of each number -- the 'weight ' is the digits of the numbers added together ( the weight of 99 would be 18 , the weight of 100 would be 1 , etc etc ) . This means that a string `` 100 54 32 62 '' would return `` 100 32 62 54 '' .I can g...
How to sort one array based on how another gets sorted ? ( Javascript )
JS : I 've used FireBug to test the two cases and they seem pretty similar by result : But I 'm pretty sure there is some difference between these two , maybe even performance related difference . Bottom line - I 'd like to know if there is a difference between { active : `` yes '' } and { `` active '' : `` yes '' } . ...
What is the difference between { active : `` yes '' } and { `` active '' : `` yes '' } ?
JS : I have a problem with touchstart in my jquery code . My jquery code does n't allow me to click any button , input or other elements when I open the page with a mobile phone . Please click this DEMO . You can click the inputs and you can write something on there . But open chrome developer console now click the inp...
I can not write any value from input on mobile device
JS : How do I write shorthand for else if statements ? I know to write when there 's only if and else . But How do I write this when there 's an else if statement ? <code> if ( showvar == `` instock '' ) { //show available } else if ( showvar == `` final3 '' ) { //show only 3 available } else { //show Not available } (...
Shorthand with else if
JS : I am creating a datatable module and I am aiming for a particular implementation . I want to be able to import the module , and use it 's components like so : randomcomponent.component.htmlHere are the components from the datatable module : datatable.component.html ( < datatable > ) column.component.html ( < datat...
How to pass data through nested ng-containers & ng-templates ?
JS : I 'm using jQuery to do ajax calls - many of which are working fine , but I 've just run into an odd problem trying to send a string to the server . I 've narrowed the code down to just this : When it hits the server however , the request variables are as follows : where Request [ `` f [ 0 ] '' ] contains `` u '' ...
JavaScript String object is being split into an array on jQuery.post
JS : i just read meteor 's accounts config options , `` restrictCreationByEmailDomain '' option is awesomei want to know can i use a list of domains separated by comma or array in place of 'school.edu'is there any simple tutorial for meteor accounts system ? pls help <code> Accounts.config ( { restrictCreationByEmailDo...
how meteor 's restrictCreationByEmailDomain option work ?
JS : So I have 2 check-boxes : When I click a checkbox it adds it to a JavaScript list , if it 's already in the list I want to overwrite it with another value ( 123 in this example ) .But when I click the second one ( does n't matter the order , the 2nd element is always 123 for some reason.Where as I would expect if ...
Why is Javascript equating 5 == 8 as true ?
JS : This is the situation : I modified it this way and it works as expected : I am wondering if there is a more elegant way to write this , maybe something that has a property check . [ UPDATE ] : There are various ways to solve this.If you do n't need to retain user properties : or the proposal spread property : Othe...
Best way to handle multiple assignment of the same property in javascript
JS : Can anyone explain what this statement means ? Specifically , This appears in a chunk of code I am looking at . I 'm not at a complete loss , however My understanding is that it assigns both e and window.event ( or x/whatever ) to e. It 's only natural , right ? But what is the value in assigning e to e ? Should n...
Can someone please explain e = e || x ? Why assign e to e ?
JS : Say I had the following markup : And I use the following to retrieve them : How is it possible that I am able to retrieve the respective DOM element by using the [ ] syntax and also be able to call methods on the jQuery object such as .first ( ) ? I 'm asking this question because it looks to me that divs is a jQu...
How does jQuery allow you to use [ ] on a jQuery object ?
JS : In my local domain 's webpage , bothjq.src = `` https : //cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.js '' ; jq.src = http : //127.0.0.1/js/jquery-3.3.1.min.jscan be loaded . In the stackoverflow 's webpage , right click to enter into chrome 's inspect -- console.The remote jquery.js file can be loaded , n...
Why ca n't load js file in my local apache2 server ?
JS : Do Windows 8 JavaScript apps support GIF images ? If so , how can I display the GIF image ? I tried this below code but it was n't working : UpdateI do n't need a C # app . I need a JavaScript app . <code> < img id= '' backround '' src= '' images/header.gif '' / >
Do Windows 8 JavaScript apps support GIF images ?
JS : I have many difficulties in doing this kind of formatting in the field . I have a form field : The intention is to make this field be in the following format , when a person enters 2 numbers the field automatically places a `` / `` forming the following type `` 2 / 2 / 4 `` insofar as the person is typing . Howeve...
Date format with onchange
JS : I added a video background , everything works except that Google Chrome and Firefox are showing black edges when I 'm playing the video ( see image ) . When I ran the page on Edge and internet explorer the edges did not appear.EDIT : I know the black edges are because I put the container as a black background but ...
Google chrome showing black edges when playing video
JS : I 'm looking to get all the elements that end with a number.So for an example we have a < a > with this href.Now I can get all of the occurences of the href with : However that also gives me results such asSo what I want is that I can only get the hrefs ending with a number to an array . I really would n't want to...
How to search for href ending with numbers with querySelectorAll ( )
JS : I 'm trying to build a responsive footer , but this is maybe interesting for other responsive elements , too.Is there a possibility to hide an element , if the line breaks at its position ? I want for wide screens : And for smaller screens then for example : oretc.So the dividing dot disappears if there is a line ...
hide element after line-break
JS : I have the back to top button that appears when you reach a point on the page , which is working fine , however , when it appears the text is on two lines until the box has finished the animation to appear . So , is there anyway to prevent this ? What I mean by the animation is : btt.show ( 'slow ' ) ; Code : Exam...
Javascript button appear animation
JS : I know a lot of JavaScript libraries are depending on `` ontouchstart '' to detect if it 's on tablet or a desktop.Here 's an example of code I 'm talking about : For now , I had to comment out all the tablet detection code for it to work.What would be the best way of detecting a tablet vs a desktop ? Thanks ! <co...
Chrome 22 confuses tablets and desktops
JS : I am currently working with minification of JS files for improvement of page speed . I have been able to find the simplest method that works with almost all my js files in exception of two . The problem is with the js files for a wmd editor I am trying to implement to my site . The js files wmd.js and showdown.js ...
Compression and mergin of JS files with PHP- Text editor
JS : I 'm trying to apply image filters to an image and have the file element be recreated every time a filter is clicked . Thus , the would be pseudo code . Its still saying the file field is null and im not sure why . I 'm trying to pass the file to my php script that handles uploads but im not sure how to do that in...
Uploading a cloned canvas photo by dynamically creating a html file element with the default value being the canvas image
JS : I 've seen others using the following pattern . But why ? I can see the point if both were declared , but they 're not . Why is the reason ? <code> var bar = function foo ( ) { } ; console.log ( bar ) ; // foo ( ) console.log ( foo ) ; // ReferenceError : foo is not defined
Why JavaScript function declaration ( and expression ) ?
JS : I understand that styles can be conditionally rendered such as : This does not look DRY - How can I ( is it possible ) render an entire block of css styles based on props ? Something like : <code> const HelloWorldLabel= styled ( `` div '' ) < { centered ? : boolean } > ` display : $ { ( { centered } ) = > ( center...
Styled Components - Conditionally render an entire css block based on props
JS : I have a problem , and I would like you to guide me to solve it if you do not mind ... In my HTML source code had several pieces of css codes here and there . So I decided to put together into a file called principal.css and do the following in the head sectionThis has worked wonderfully ! My idea was to do the sa...
Move JS code from HTML to source in HEAD section
JS : I have an application that is written around the MEAN web stack . I have created an API that depending upon the URL a JSON data set is returned for given weights . This is interconnected with my Mongo database . There are two returned JSON types , one for all weights and another for weights that fall between two d...
Why will a change on $ scope.data on a onChange callback not re-plot chart.js ?
JS : I understand when using arrays of Components the key property is assumed to be the index of the array , and should be explicitly set . Are the children of those children recommended to be explicitly set ? <code> { arr.map ( item , i ) = > { < Parent key= { item.ID } > < Child key= { ` child $ { item.ID ` } //requi...
nested key property requirements in React
JS : I have the following array : I want to have the following output : How can I achieve this in JavaScript ? Already tried with recursive loop , but it does not work , gives me undefined.Thanks <code> var sampleArray = [ `` CONTAINER '' , `` BODY '' , `` NEWS '' , `` TITLE '' ] ; var desiredOutput = [ { `` CONTAINER ...
Flat array to multi dimensional array ( JavaScript )
JS : what is the difference between this regular expressions are the replaceable ? background to this question : The javascript WYSIWYG editor ( tinymce ) fails to parse my html codein Firefox ( 23.0.1 and 25.0a2 ) but works in in Chrome.I found the regular expression to blame : which I modified , replacingwithand with...
regular expressions difference between ( ( ? : [ ^\ '' ] ) * ) and ( [ ^\ '' ] * )
JS : I have simple data grid like so : * Note that I have a header and footer in seperate tables in divs above and below the uiGridContent div . That are not required for this example.The idea being that as the user scrolls down the table , it will load in the next page when they reach the bottom of the last tbody in t...
Load and remove pages of content based on scroll direction and height
JS : Well , we have a page running RequireJS , which loads the dependencies , creates the approuter and well , all backbone load.On html page , we load : And this , in principle does not fail ( Say 'Done ' ) , but it does not run any more.It not executes the code ( In main.js ) : This happens only with AdBlocks , not w...
AdBlock blocks requirejs / backbone code ( Locks the entire page )
JS : I am having trouble figuring out how to pass the objects method rather than sort `` generic prototype '' method when doing callback.I am passing the onLogin method but well it does not work . This is code I have re-written . Previously I nested all methods inside the Client function but well , I learned that that ...
Using callback function with prototype functions
JS : I 'm using angular 1.6.5 for my angular application and came across a very strange behavior.The thing I want to achieve is : when ngroute is being changed , I must remove active class from current view , wait for leave animation to complete , then add active class to the new view.I have set up app and routs in the...
Angular not updating ng-class on ng-view
JS : I 'm working on a script that allows the user to draw with the mouse : http : //jsfiddle.net/ujMGu/The problem : If you move the mouse really fast it jerks and skips a few places . Is there any way to capture all the points without any skipping black spaces in between the drawing line ? CSSJS/JQHTML <code> # myid ...
How can I prevent fast mouse movement from breaking a line in my drawing app ?
JS : I 'm using browserify-rails and I 'm trying to get sprockets to preprocess a file that contains a sprockets directive , so that when I require ( ) it using browserify , it will contain the generated JavaScript.The sprockets directive tries to include the output of the gem js-routes , in order to allow me to access...
Requiring a sprockets-preprocessed file with Browserify and browserify-rails
JS : i 'm trying to have a component only render when I have used a search button . The code below is my current codeUpdateMade the changes , Now receiving this error.error ] ERROR in /home/holborn/Documents/Work/Portfolio/Data_Scraping/Eldritch/client/pages/index.tsx ( 21,19 ) :21:19 Can not find name 'Product ' . 19 ...
Conditional Rendering in React wo n't work , state not working properly ?
JS : I am trying to create an extension off jest-node-environment as a CustomTestEnvironment but am getting the following error when trying to run jestI believe this error means it does n't recognize this as a typescript file , and has n't transpiled it . ( I am using the latest version of jest 26.0.1 ) Based on discus...
How to create Jest Custom Environment with Typescript ?
JS : I have a question regarding checking the string.The string is from a ckeditor so user can input anything.The variable name is htmlData and it is like : I want to detect if user add a table structure and I have triedbut it does n't show anything in my console . Can anyone gives a hint on this ? Thanks so much ! <co...
Detect if a string contains a table
JS : I saw this piece of code in React , likebut I failed to google any explanation.Probably the question is dumb , but I appreciate any help , maybe links to some existing explanations or examples . <code> connect ( mapStateToProps , { test : ( ) = > { return { type : 'TEST_ACTION ' } } } ) ( Index ) ;
What does the notation ( ) = > mean and how to use it ?
JS : I have a RadioButtonList with `` Not Applicable '' , `` Not Available '' , `` Leave '' and `` Available '' options.I am throwing confirm message box on click of `` Leave '' in RadioButtonList from Server side as belowIf user clicks `` Cancel '' , then it will automatically selects `` Available '' with below code ....
RadioButtonList not firing SelectedIndexChanged every time
JS : I am attempting to write a function that will convert anything into a function . The function should work as follows : Check to see if it already is a function and if so just returns it.Check to see if it is a string and if so is there a global function with that name , if so return that.Check to see if the string...
In JavaScript , can I check to see if a string can be evaluated without actually evaluating it ?
JS : I want to do something on all clicks except on a certain element . I 've created a very simple example which demonstrates the issue : http : //jsfiddle.net/nhe6wk77/.My code : I 'd expect all click to on < a > to be ignored , but this is not the case.Am I doing something wrong or is this a bug on jQuery 's side ? ...
Delegated events do n't work in combination with : not ( ) selector
JS : I want to programmatically hide and show my embedded aframe scene . The scene is hidden when the website is loaded , however I only get it to work with a delay like this : When I do n't add this delay , the scene remains hidden , even after setting it to 'visible ' again . Specifically , the size of the canvas see...
Hiding an embedded aframe scene
JS : I 've a sample example below , I 'm not sure why the first example ( using div 's ) did n't get the text when the second one ( using span 's ) could achieve that with the same JS code using closest ( ) : First snippet ( using div 's ) cant get the text using closest ( ) : Second snippet ( using span 's ) getting t...
closest ( ) method not working as expected
JS : Would someone explain why formatting the same dateString differently gives a different date ? <code> > new Date ( `` 04/08/1984 '' ) < · Sun Apr 08 1984 00:00:00 GMT-0600 ( Mountain Daylight Time ) > new Date ( `` 1984-04-08 '' ) < · Sat Apr 07 1984 18:00:00 GMT-0600 ( Mountain Daylight Time )
Javascript new Date ( dateString ) handling
JS : I 've inherited a rather large Javascript/ExtJS3 code base , and there are many instances of invoking events inside of the overridden initComponent method , after the call to `` ... superclass.initComponent.apply ( this , arguments ) '' . Specific events are being invoked on specific objects in a manner such as th...
Is publishing/subscribing to events after UI rendering a best practice regardless of framework ?
JS : GoalI would like to write a javascript library ( framework ) , but need OOP and mixins.Was giving a go to typescript , but it does n't support mixins ( the handbook says it does , but the compiler/specifications has nothing that is mixin related ) .TypescriptIn typescript , the following code : Compiles to : Then ...
Can dart produce readable javascript libraries ?
JS : I do n't know if this is possible in css , I am sure that it can be done in js but i do n't know how ... I have a div with a background and a text that is in another div with another background . What I would like is the text to be transparent and have the first-background as the text background . I do n't know if...
Transparent text which ignores the first background
JS : So basic desctucturing is fine , { a , b } = obj transpiles to a = obj.a ; b = obj.b.My question is around a bit of an odd syntax that I accidentally ran across and I 'm wondering if someone can point me at spec since I ca n't find it : That does the two a , b assignments and then returns obj.c . It 's actually qu...
Is Babel 's implementation of ES6 object destructuring correct ?
JS : I have a form with two fields : The error div is always displayed when the password field is empty - I only want it to display if the password has been focused and then blurred . Is there a simple change I can make to enable this ? <code> < form name= '' form '' > < input type= '' email '' ng-model-options= '' { u...
Angular Form - `` Required '' with ng-model-options
JS : My ultimate goal is to use Yarn Workspaces in a project using Browserify and Babel 7 . This is a minimal reproduction of a problem I 'm having . Basically it seems that the presence of a package.json file in a subfolder ( which is one of the things that you have when using Yarn Workspaces ) breaks my Browserify bu...
Yarn Workspaces and Browserify - package.json in subfolder breaks the build
JS : I am very confused as to why only the last element is inserted when I try to append multiple elements within a for loop.I have created a JsFiddle showcasing my inability to get it to work . I expect 100 anchor tags to be inserted , yet only the last element is inserted.For posterior 's sake , here 's the relevant ...
How to insert multiple elements into one element via append in a for loop ?
JS : I have a process to get images in node.js using either jsdom or Canvas . During the download process , I want to extract swatches using Vibrant.js in the backend . Neither of my code below works.Using jsdomUsing CanvasI could use URL in Vibrant.js but that 's another http GET using Bluebird and I need to avoid cal...
Get Vibrant.js swatches using jsdom or Canvas for node.js
JS : People is a nested class . Its parent class is Family.I get the error that Family.People is undefined . Could someone correct the code above ? <code> Family = function ( name ) { this._Name = name ; } Family.prototype = { getName : function ( ) { return this._Name ; } , People : function ( num ) { this._Number = n...
Javascript prototype and issues accessing class
JS : is it OK to use the more than 1 time in the javascript code ? <code> $ ( document ) .ready ( function ( ) { // some code } ) ;
Jquery - More than 1 `` $ ( document ) .ready '' = dirty code ?
JS : Is there a better way to check if an object is empty ? I 'm using this : <code> function isObjEmpty ( obj ) { for ( var p in obj ) return false ; return true ; }
Empty JS Object
JS : My Angular app is developed using a boilerplate of this yeoman generator.Routing and all things working fine but I could not get to working $ scope only on navbar-controller.js and footer-controller.js . Please tell me if you need more information to give a clue about this.Index.htmlnavbar-controller.jsnavbar-modu...
$ scope not working in my nav bar controller ?
JS : I 'm having an issue that only appears to affect IE and Edge ( tested on IE9-11 & Edge 12-13 ) . I 'm animating an SVG stroke offset with Snap.svg which seems to run fine but at certain points the stroke appears to go `` out of bounds '' and disappear . It 's odd since the viewBox is set to clearly fit the line ( ...
SVG animation appears `` out of bounds '' on IE & Edge
JS : Is there a better way than this to create a callback function for some random function ? The callback function does n't have any parameter when I utilize it , I only do like this : <code> var showObj = function ( obj , callback ) { return setTimeout ( function ( ) { if ( opts.centerObj == true ) { var cssProps = g...
Best Way To Create A Callback Function
JS : I am having some weird issue with ng-class , and I am suspecting that it has to do with race condition.Here is plunker exampleHere is the relevant js codeHere is the relevant htmlHere is the animation.This is a simple app that slide a list of number left and right.If the left button is pressed , the numbers slide ...
Race condition with ng-class and animation
JS : Is it possible to configure ESLint in WebStorm so functions , variables , etc . are parsed also from files in the same folder ? In my build process , I concatenate all files in the same folders into big closures , for example : I would like ESLint to treat all those files just like one , so I do n't get `` undef '...
Use all files in a folder like a one big JS
JS : I have recently been assigned to take over and clean up an Angular project that is already complete and in production . This is my first time using Angular.Everything I 've read so far on Angular ... https : //www.airpair.com/angularjs/posts/top-10-mistakes-angularjs-developers-makehttp : //nathanleclaire.com/blog...
How do I properly implement DOM manipulation in Angular ?
JS : I have an application which allows users to pick some time slots . By default the timeslots are empty , and my .NET back-end has default generated values of type DateTimeOffset , which by default are set to `` 0001-01-01T00:00:00+00:00 '' .Now , when I populate a date on the front-end with this value , it generate...
Wrong minutes and seconds in a JavaScript date before year 1925
JS : It is clear , how does the method work : But , why do I need such mechanism ? For which use-cases ? <code> f = [ ' a ' , ' b ' , ' c ' , 'd ' , ' e ' , ' f ' , ' g ' , ' h ' ] ; console.log ( f.copyWithin ( 4,2,5 ) ) ; // copy elements between 2 ( start ) & 5 ( end ) - > to target - > 4 // [ ' a ' , ' b ' , ' c ' ...
For which use cases does Array.prototype.copyWithin ( ) exist ?
JS : People here are using visual studio for performance testing . Now there are some small issues with some javascript parts : they are not able to check the performance of the javascript part with visual studio web-performance testing.I never used visual studio performance test , so I really have no idea how to bench...
Read JS variable in C # / Forwarding JS variable to visual studio performance test ?
JS : I do n't know exactly how to name this or how to explain it , so I 'll give you some examples of what I have and what I want to create ... I have a list of divs , all of them with an own style , in a way that they look as Forums and sub-forums ... Here I 'll show a picture of what I have : The code is simple : And...
Dashed-styled list linking divs
JS : I 'm trying to duotone an image and plaster it onto a canvas.Works in desktop browsers : ChromeFirefoxSafariInternet ExplorerFails in mobile browsers : AndroidWorkable demo on JSFiddle , this example works in Chrome but fails in Android 's default browser . The code is : The summary is : set the background color t...
Image alpha on default Android browser
JS : trying to set up random background images for my Jumbotron . Here is what I have so far . This works however on page load the styles defined in my css sheet seem to be overwritten ? Is there a way to load these random images and keep the other styles already defined ? Also , another quick question.. I used getElem...
Javascript Random Image Losing Styling
JS : I was trying to make a pipe in typescript that would split a PascalCase string , but it would be nice if this would also split on digits as well . I would also like it to split on consecutive capital letters . I have this pipe , which works great , except it only works in Chrome and not Firefox , evidently only Ch...
Split a string on a capital letter or numbers
JS : I 'm trying to display the image using cover simulation in canvas . I 've found some cool answer on how to do it.The thing is when I do it with a large picture , it 's being displayed ugly . How to fix that ? Here 's my CodepenHTMLCSSJS <code> < canvas id= '' canvas '' > < /canvas > canvas { width : 100 % ; height...
Getting ugly image while simulating cover in canvas
JS : Question is bit crazy . Is there any possibility to using variable name instead of another , clearly , consider the following code where I have to switch over to any variable name `` people '' or `` student '' accordingly <code> var people= [ { name : '' akash '' , age:25 } , { name : '' abi '' , age:22 } ] ; var ...
using variable name in lodash collection
JS : I have a class like so : How would I turn the send method into a promise , which returns a value from the socket 's data event ? The server only sends data back when data is sent to it , other than a connection message which can easily be suppressed.I 've tried something like : Obviously this wo n't work because r...
How can I control program flow using events and promises ?
JS : I 'm attempting to create something of a tree structure.I wish to access my data as follows : However , key1 and key2 have a symmetric relationship ; the following is always true : More specifically , I have data [ key1 ] [ key2 ] and data [ key2 ] [ key1 ] pointing to the same object , such that changes to one af...
javascript - objects immutable ?
JS : I 'm working on a project that uses MongoDB , but I 've never worked with it.I understand that by using javascript , you can manipulate the database . I made a script that removes some fields and adds some others , but it does n't work properly : When db.floor.save ( doc ) is called , my floor is saved . All tiles...
MongoDB adding and removing fields in array