Javascript syntax error

Hi, Dreamweaver indicates an error in the 4th line here -  ".catch( error => )" - ...can someone explain it to me please?  I have taken this from the CKeditor tutorial so it shouldn't error!

<script>
    ClassicEditor
        .create( document.querySelector( '#txtBody' ) )
        .catch( error => {
            console.error( error );
        } );
</script>
LVL 3
Colin BrazierAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

käµfm³d 👽Commented:
What version of JS/ES does your Dreamweaver support? Lambda syntax is new as of ES6.

You can try changing to standard function syntax to see if the error goes away:

 .catch( function (error) {

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Colin BrazierAuthor Commented:
So this is a new js syntax?
Colin BrazierAuthor Commented:
Yes it has gone away - thanks. Crikey, I can't understand the old syntax, let alone a new one ;)
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

Colin BrazierAuthor Commented:
OK so now I see js is being given a facelift........cheers for helping out.
käµfm³d 👽Commented:
So this is a new js syntax?
Yes.

I can't understand the old syntax, let alone a new one
Either syntax is basically creating a nameless function definition. Normally you would do something like this:

function SomeMethod() {
    // some things to do
}

Open in new window


...and you would invoke it like this:

SomeMethod();

Open in new window


But with a nameless (a.k.a. anonymous) method, you can't invoke the method using a name--there isn't one. But that doesn't preclude you from invoking that method in other ways. A function could take a function as one of its arguments. In this way, you have a variable that points to a function. You can invoke that variable.

function SomeOtherMethod(callback) {
    // some things to do

    callback();    // invoke the variable because we expect it points to a function
}

SomeOtherMethod(function () {
    alert('Hello World!');
});

Open in new window


You could similarly assign an anonymous function to a variable and invoke it similar to actually giving it a name:

var x = function () {
    alert('Hello World!');
};

x();    // Invoke variable

Open in new window


The function still doesn't have a name, but the fact that the variable points to said function means you can invoke the variable as if it were the name of the function.
Colin BrazierAuthor Commented:
Brilliant, thanks!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.