Blog

JavaScript articles

Resolving an accessor cannot be declared in ambient context error

Resolving an accessor cannot be declared in ambient context error

Posted: Saturday 15th February, 2020 - 2:33pm
Author: James Griffiths

Nothing puts the brakes on wanting to get stuck into coding quite like an unexpected (and very much unwanted) compiler error.

Case in point: being greeted with the following error in a recent Ionic 4 project:

ERROR in node_modules/@angular/animations/browser/browser.d.ts:135:9 - error TS1086: An accessor cannot be declared in an ambient context.h

 .....great :(

Read more...
Resolving CUSTOM_ELEMENTS_SCHEMA error with unit testing Angular 7 components

Resolving CUSTOM_ELEMENTS_SCHEMA error with unit testing Angular 7 components

Posted: Thursday 21st March, 2019 - 9:09pm
Author: James Griffiths

Created custom components with your Angular 6/7 applications and finding your unit tests failing with the following error(s):

'mi-accordion' is not a known element:
1. If 'mi-accordion' is an Angular component, then verify that it is part of this module.
2. If 'mi-accordion' is a Web Component then add "CUSTOM_ELEMENTS_SCHEMA" to the '@NgModule.schema' of this component

Here's how to fix that...

Read more...

Exploring ECMAScript 6 - Array manipulation

Posted: Saturday 6th February, 2016 - 6:38pm
Author: James Griffiths

ECMAScript 6, commonly referred to as ES6, is the latest ECMAScript language specification that defines the standards for implementing JavaScript in web browsers. ES6brings with it lots of powerful new features that provide developers with more flexibility than ever when crafting their applications.

In the following article we're going to take a look at manipulating arrays in ES6.

Read more...

Remove an item from a JavaScript array by value

Posted: Monday 1st February, 2016 - 6:35pm
Author: James Griffiths

No matter how much you work with a given tool there will always be those 'aha' moments when you learn something new that you didn't realise was possible before.

One of those 'aha' moments was when we discovered the filter method in JavaScript.

Read more...

Using the revealing prototype pattern in JavaScript

Posted: Saturday 30th January, 2016 - 6:28pm
Author: James Griffiths

When developing applications with JavaScript you quickly realise the need to architect and structure your code in a way that's modular, scalable and efficient.

Due to JavaScript's flexibility there are many ways this could be achieved; some better than others.

In this article we're going to take a look at how this could be achieved using the revealing prototype pattern and discuss the benefits and drawbacks of this particular design pattern...

Read more...

Generating JSON objects dynamically in JavaScript

Posted: Saturday 26th September, 2015 - 10:09pm
Author: James Griffiths

Working with JSON provides front-end developers with many advantages over other data formats, least of which is the fact that it's a subset of the JavaScript language itself.

In this short tutorial we'll take you through dynamically generating a JSON object within JavaScript...

Read more...

Understanding the JavaScript revealing module pattern

Posted: Saturday 12th September, 2015 - 9:59pm
Author: James Griffiths

As our JavaScript applications start to become more complex and demanding it makes sense to turn towards using specific design patterns as a way of managing those needs. In this particular article we're going to take a look at one particular design pattern: the revealing module.

Read more...

JavaScript namespacing and modules

Posted: Saturday 12th September, 2015 - 9:52pm
Author: James Griffiths

As JavaScript has, at the current time of writing, no native support for namespaces we, as developers, have to implement our own approaches/solutions to avoid polluting the global namespace with objects/methods and variables that might conflict with/overwrite one another if we are not careful.

In this article we take you through using namespaces and modules to better manage your code.

Read more...

Measuring Javascript performance and debugging with browser inspector tools

Posted: Friday 4th September, 2015 - 10:11am
Author: James Griffiths

As JavaScript has become a central pillar of front-end web development, thanks to modern browser support, the tools we need to measure how our scripts are performing have become increasingly important.

In this article we're going to take a look at some of these tools that are available directly within the Google Chrome browser...

Read more...

Resolving CORS issues with Ajax requests

Posted: Sunday 26th July, 2015 - 6:41pm
Author: James Griffiths

Ajax makes life as a web developer a lot easier, particularly when used with a framework such as jQuery but, like all development related technologies, there will always be gotchas that can catch you unawares.

One of those is CORS...

Read more...

Using Google Maps in Angular JS

Posted: Tuesday 10th March, 2015 - 8:27pm
Author: James Griffiths

Angular JS, once you switch from a jQuery mindset, makes building out web apps relatively quick and thanks to the growing number of available plug-ins you can be sure to find a solution to fit your development needs.

One such need might involve implementing Google Maps which is what we are going to look at through this tutorial.

Read more...

Scrolling to a page anchor in Ionic Framework

Posted: Tuesday 17th February, 2015 - 8:03pm
Author: James Griffiths

If you've been working with the Ionic Framework you'll be familiar with setting up AngularJS routes for your controllers and view templates which are then triggered with hyperlinks used within your App. The combination of Ionic and AngularJS makes this easy to implement but when it comes to scrolling to a particular anchor inside a view template things get a little trickier.

Read more...

Documenting JavaScript with YUIDoc

Posted: Saturday 16th August, 2014 - 8:23pm
Author: James Griffiths

You either love it or you loathe it but as developers we all need to do it: documenting our code.

Given the ever increasing need for more complex JavaScript apps the ability to quickly understand what is going on (and more importantly, why) in the scripts we use can be helped along with the right kind of documentation.

Enter YUIDoc...

Read more...

JavaScript development in the browser console

Posted: Sunday 10th August, 2014 - 8:10pm
Author: James Griffiths

One of the great things about modern website development is the range of tools available to developers and nowhere is this truer than within modern website browsers. In fact, one of the most powerful and often under-utilised tools is that of the browser console.

Read more...
Page 1 of 2
Top