Here's a great example showcasing asynchronous programming in JavaScript. To delve deeper into this topic, check out Protractor: Exploring the variance between ignoreSynchronization and async/await in Protractor. This will provide clarity on how the execution process unfolds.
To address your query, consider implementing async/await instead of .then to capture and save the value.
it('should retrieve count', async () => {
await browser.get("application URL");
let count = await element.all(by.xpath("//div[@class='notification-content']")).count();
console.log(count);
});
Hoping this resolves your question.
Edit:
it("test", () => {
let count1, count2;
browser.get("application URL");
var notifications = element.all(by.xpath("//div[@class='notification-content']"));
count1 = notifications.count();
var notifications = element.all(by.xpath("//div[@class='notification-content']"));
count2 = notifications.count();
expect(count1).toBe(count2);
});